ICComputerPlayer


Inherits From:
ICPlayer
Declared In:
ICComputerPlayer.h


Class Description

ICComputerPlayer is an abstract superclass of all computer players. It contains a number of convenience methods to simplify the design of computer players.


Method Types

Turning in cards
- turnInCardsIfPossible
Placing armies
- allocateArmiesRandomly
- allocateArmiesToMostThreatenedCountries
- allocateArmiesRandomlyToMostThreatenedCountries
- allocateArmiesToAttackers
Attacking
- attackVulnerableCountries
- attackRandomCountries
- attackVictimsWithAttackers
- pickAttackersAndVictims
- calculateAttackPaths
- attackers
- setAttackers:
- victims
- setVictims:
Defending
- armiesToReserveForDefense
- fortifyVulnerableCountries
- updateReserveArmies

Instance Methods

allocateArmiesRandomly

- (void)allocateArmiesRandomly

Randomly places armies in the destination countries.


allocateArmiesRandomlyToMostThreatenedCountries

- (void)allocateArmiesRandomlyToMostThreatenedCountries

Same as allocateArmiesToMostThreatenedCountries, except distributes armies a little more evenly and less predictably. Specifically, most armies are placed in the most threatened few countries, while a few armies are randomly distributed among the other countries.


allocateArmiesToAttackers

- (void)allocateArmiesToAttackers

For each victim country, while there are unallocated armies, places enough armies in the country that will be used to attack the victim to have a good chance of counquering the victim.


allocateArmiesToMostThreatenedCountries

- (void)allocateArmiesToMostThreatenedCountries

Places armies in the most threatened destination countries. While there are unallocated armies, places an army in the most threatened country. The threat level is defined as the number of adjacent enemy armies minus the number of armies.


armiesToReserveForDefense

- (float)armiesToReserveForDefense

The portion of armies to reserve for defense. If this method returns 0.0, all armies will be used for attacking. If it returns 1.0, no armies will be used for attacking.


attackRandomCountries

- (BOOL)attackRandomCountries

Tells each of the player's countries to randomly attack their neighbors. Returns NO if the player conquers a country. Returns YES if there are not enough armies to continue attacking.


attackVictimsWithAttackers

- (BOOL)attackVictimsWithAttackers

Tries to attack each country in the victims array.


attackVulnerableCountries

- (BOOL)attackVulnerableCountries

Tells each of the player's countries to attack their most vulnerable neighbors. Returns NO if the player conquers a country. Returns YES if there are not enough armies to continue attacking.


attackers

- (NSMutableArray *)attackers

The countries you would like to attack from.


calculateAttackPaths

- (void)calculateAttackPaths

Calculates attack paths for all countries. After calling this method, every unowned country will have its attackPath array set to the countries along the optimum attack path from an owned country.


fortifyVulnerableCountries

- (void)fortifyVulnerableCountries

Sends the fortifyArmiesFrom: message to all countries with armies that can be moved.


pickAttackersAndVictims

- (void)pickAttackersAndVictims

Override this method to pick attackers and victims. You should call this method before placing armies at the beginning of hte turn. It will also be called by attackVictimsWithAttackers if all the victims have been conquered.


setAttackers:

- (void)setAttackers:(NSMutableArray *)value

Sets the countries you would like to attack from. You may call this method from your implementation of pickAttackersAndVictims. When attacking using attackVictimsWithAttackers, attacks are actually launched from the first country in each country's attackPath.


setVictims:

- (void)setVictims:(NSMutableArray *)value

Sets the countries you would like to attack. You should call this method from your implementation of pickAttackersAndVictims.


turnInCardsIfPossible

- (void)turnInCardsIfPossible

Checks to see if there are sets of cards that can be turned in. If so, turns them in. This method can be called by assignArmiesFromIncome.


updateReserveArmies

- (void)updateReserveArmies

Sets aside a certain portion of armies in each of the player's countries to use for defense. These armies will not be used when attacking. The portion used for defense is determined by the value returned by armiesToReserveForDefense.


victims

- (NSMutableArray *)victims

The countries you would like to attack. The method attackVictimsWithAttackers will try to attack the countries in victims.


Version 1.1 Copyright ©2003 by KavaSoft. All Rights Reserved.