games.strategy.triplea.strongAI
Class SUtils

java.lang.Object
  extended by games.strategy.triplea.strongAI.SUtils

public class SUtils
extends java.lang.Object


Constructor Summary
SUtils()
           
 
Method Summary
static java.util.List<Territory> ACTerritory(PlayerID player, GameData data)
          Returns a list of all territories containing owned AirCraft Carriers
static void addUnitCollection(java.util.List<java.util.Collection<Unit>> aUnits, java.util.Collection<Unit> bUnits)
           
static float airstrength(Unit airunit, boolean attacking)
          Determine the available strength of a single air unit Primarily useful for a sea battle needing support Moved from AIUtils to improve portability with changes by others
static boolean airUnitIsLandable(Unit u, Territory source, Territory target, PlayerID owner, GameData data)
           
static boolean airUnitIsLandableOnCarrier(Unit u, Territory source, Territory target, PlayerID player, GameData data)
           
static float allairstrength(java.util.Collection<Unit> units, boolean attacking)
          Determine the strength of a collection of airUnits
static java.util.List<Territory> allAlliedTerritories(GameData data, PlayerID player)
          All Allied TErritories in a modifiable List
static java.util.List<Territory> allEnemyTerritories(GameData data, PlayerID player)
          All Enemy Territories in a modifiable List
static java.util.List<Territory> allOurTerritories(GameData data, PlayerID player)
          Territories we actually own in a modifiable List
static java.util.Collection<Territory> bomberTerrInList(java.util.List<java.util.Collection<Unit>> units, java.util.List<Route> routes)
          Determine if a List has any bombers in it
static void breakUnitsBySpeed(java.util.List<java.util.Collection<Unit>> returnUnits, GameData data, PlayerID player, java.util.List<Unit> units)
          Create a List which contains a series of collections each which has a different movement
static boolean calculateTUVDifference(Territory eTerr, java.util.Collection<Unit> invasionUnits, java.util.Collection<Unit> defenderUnits, java.util.HashMap<PlayerID,IntegerMap<UnitType>> costMap, PlayerID player, GameData data, boolean aggressive, boolean subRestricted)
           
static Territory closestAmphibAlliedTerritory(Territory startTerr, Territory targetTerr, java.util.List<Territory> contiguousTerritories, GameData data, PlayerID player, boolean tFirst)
          Return the closest allied Territory to targetTerr Creates a list of the top 3 closest points and then returns the one with the maximum # of units Always returns a neighbor of startTerr if the neighbor is in the top 3
static Territory closestEnemyCapital(Territory startTerr, GameData data, PlayerID player)
          Find enemyCapital closest to startTerr
static Territory closestToEnemyCapital(java.util.List<Territory> ourTerr, GameData data, PlayerID player, boolean byLand)
          Takes a List of territories and finds the one closest to an enemy capitol by Land
static void continentAlliedUnitTerr(GameData data, PlayerID player, Territory startTerr, java.util.List<Territory> contiguousTerr, java.util.List<Territory> ignoreTerr)
          Return a list of Territories on a Continent which are allied
static IntegerMap<UnitType> convertListToMap(java.util.Collection<Unit> units)
          Map a list of units
static boolean determineAggressiveAttack(GameData data, PlayerID player, float aggressiveFactor)
          use TUV for a set of allies and their enemies to determine if TUV superiority indicates that a player can be more aggressive in an attack.
static float determineEnemyBlitzStrength(Territory blitzHere, java.util.List<Route> blitzTerrRoutes, java.util.List<Territory> blockTerr, GameData data, PlayerID ePlayer)
          Determine the enemy potential for blitzing a territory - all enemies are combined
static int determineTUV(IntegerMap<UnitType> unitList, IntegerMap<UnitType> unitCost)
           
static int distanceToEnemy(Territory t, java.util.List<Territory> beenThere, GameData data, PlayerID player, boolean sea)
          Recursive routine for finding the distance to an enemy
static boolean doesLandExistAt(Territory t, GameData data, boolean neutral)
          Does this territory have any land?
static int evaluateNonCombat(int numMoves, int evalDistance, java.util.HashMap<java.lang.Integer,java.util.HashMap<Territory,java.lang.Float>> reinforcedTerrList, java.util.HashMap<java.lang.Integer,IntegerMap<Territory>> unitCountList, PlayerID player, GameData data, boolean tFirst)
           
static Territory findASeaTerritoryToPlaceOn(Territory landTerr, GameData data, PlayerID player, boolean tFirst)
          Look for an available sea Territory to place sea Units if other owned sea units exist, place them with these units Otherwise, look for the location which is least likely to get them killed
static java.util.List<Territory> findCertainShips(GameData data, PlayerID player, Match<Unit> unitCondition)
          Return All Territories containing a Certain Owned Unit (Land, Sea or Air) specified by unitCondition
static Territory findFactoryTerritory(GameData data, PlayerID player, float risk, boolean buyfactory, boolean onWater)
          determines a suitable Territory for a factory suitable: At Least 2 PU All Territories around it are owned Strength of Units in the Territory and 1 Territory away Is greater than the sum of all enemy Territory 2 away Territory should be closest to an enemy Capital
static Route findNearest(Territory start, Match<Territory> endCondition, Match<Territory> routeCondition, GameData data)
          Find the Route to the nearest Territory
static Route findNearestMaxContaining(Territory start, Match<Territory> endCondition, Match<Territory> routeCondition, Match<Unit> unitCondition, int maxUnits, GameData data)
          Find Route from start to a Territory having endCondition which has a maximum of a certain set of Units (unitCondition)
static Territory findNearestMaxUnits(PlayerID player, GameData data, Territory t, boolean friendly)
          Finds the Territory within 3 Territories which has a maximum # of units Uses friendly to determine if we are looking for our guys or enemy Returns Territory with a maximum # of units (enemy or friendly)
static Route findNearestNotEmpty(Territory start, Match<Territory> endCondition, Match<Territory> routeCondition, GameData data)
           
static java.util.List<Territory> findOnlyMyShips(Territory t, GameData data, PlayerID player, Match<Unit> unitCondition)
          Identical to findOurShips...just owned rather than allied Could be merged with findOurShips with a boolean for allied Finds all units within 3 Territories of t which match unitCondition returns the List
static java.util.List<Territory> findOurPlanes(Territory t, GameData data, PlayerID player)
          Returns list of territories within 4 territories of t and contain owned planes
static java.util.List<Territory> findOurShips(Territory t, GameData data, PlayerID player)
          Returns all Territories which contain Allied Units within a radius of 4 Territories of t Works for land units as well as ships
static java.util.List<Territory> findOurShips(Territory t, GameData data, PlayerID player, Match<Unit> unitCondition)
          Returns a list of Territories containing Allied Ships within a radius of 3 which meet the condition
static boolean findPurchaseMix(IntegerMap<ProductionRule> bestAttack, IntegerMap<ProductionRule> bestDefense, IntegerMap<ProductionRule> bestTransport, IntegerMap<ProductionRule> bestMaxUnits, IntegerMap<ProductionRule> bestMobileAttack, java.util.List<ProductionRule> rules, int totPU, int maxUnits, GameData data, PlayerID player, int fighters)
          Take the mix of Production Rules and determine the best purchase set for attack, defense or transport So much more that can be done with this...track units and try to minimize or maximize the # purchased
static java.util.List<Territory> findUnits(Territory t, GameData data, Match<Unit> unitCondition, int maxDist)
          Returns a list of territories within maxDist which meat the requirement of unitCondition No requirements of ownership or allied units
static java.util.List<Territory> findUnitTerr(GameData data, PlayerID player, Match<Unit> unitCondition)
          Return Territories containing any unit depending on unitCondition Differs from findCertainShips because it doesn't require the units be owned
static int getAlliedEnemyTUV(GameData data, PlayerID player, boolean allied)
          Determine TUV for allies/enemies
static Territory getAlliedLandTerrNextToEnemyCapital(int minDist, Territory capTerr, Territory fromTerr, GameData data, PlayerID player)
          Looking for the closest land territory next to an enemy capital which is owned by an ally Use this for dumping units from transports
static java.util.List<PlayerID> getAlliedPlayers(GameData data, PlayerID player)
           
static Territory getClosestWaterTerr(Territory target, Territory source, GameData data, PlayerID player, boolean allowEnemy)
          find the water terr next to target which is closest to the source target: land destination source: present location minDist: actual distance from source to resulting water terr Returns null if target has no water territories
static java.util.List<Territory> getEnemyCapitals(GameData data, PlayerID player)
          List containing the enemy Capitals
static java.util.List<PlayerID> getEnemyPlayers(GameData data, PlayerID player)
          Returns a list of all enemy players
static java.util.List<Territory> getExactNeighbors(Territory territory, int distance, PlayerID player, boolean neutral)
          Gets the neighbors which are exactly a certain # of territories away (distance) Removes the inner circle neighbors neutral - whether to include neutral countries
static int getLeftToSpend(GameData data, PlayerID player)
          Returns the players current pus available
static Route getMaxSeaRoute(GameData data, Territory start, Territory destination, PlayerID player, boolean attacking, int maxDistance)
           
static java.util.List<Territory> getNeighboringEnemyLandTerritories(GameData data, PlayerID player)
          All the territories that border one of our territories
static java.util.List<Territory> getNeighboringEnemyLandTerritories(GameData data, PlayerID player, boolean allied)
          All territories that border our terr or allied terr boolean allied - search for enemies of allied territories, not just owned
static java.util.List<Territory> getNeighboringEnemyLandTerritories(GameData data, PlayerID player, Territory check)
          All the territories that border a certain territory
static java.util.List<Territory> getNeighboringLandTerritories(GameData data, PlayerID player, Territory check)
          All Allied Territories which neighbor a territory This duplicates getNeighbors(check, Matches.isTerritoryAllied(player, data))
static java.util.List<Territory> getNeighboringNeutralLandTerritories(GameData data, PlayerID player, boolean allied)
          All neutral territories that border our terr or allied terr boolean allied - search for neutral near allied territories, not just owned
static java.util.HashMap<PlayerID,IntegerMap<UnitType>> getPlayerCostMap(GameData data)
          Generate HashMap of the costs of all players
static IntegerMap<PlayerID> getPlayerTUV(GameData data)
          Determine the current TUV strength of all players
static Territory getSafestWaterTerr(Territory target, Territory source, java.util.List<Territory> ignoreTerr, GameData data, PlayerID player, boolean allowEnemy, boolean tFirst)
           
static float getStrengthOfPotentialAttackers(Territory location, GameData data, PlayerID player, boolean tFirst, boolean ignoreOnlyPlanes, java.util.List<Territory> ignoreTerr)
          Returns the strength of all attackers to a territory differentiates between sea and land attack determines all transports within range of territory determines all air units within range of territory (using 2 for fighters and 3 for bombers) does not check for extended range fighters or bombers
static java.util.List<Territory> getTerritoriesWithEnemyNeighbor(GameData data, PlayerID player, boolean allied, boolean neutral)
          All allied Territories which have a Land Enemy Neighbor
static Route getTwoRoute(Territory t1, Territory t2, Match<Territory> condition, java.util.List<Territory> blockedTerr, GameData data)
          Make a two step route in which the condition only applies to the middle territory in the route and not the target
static java.util.List<Unit> getUnitsUpToStrength(double maxStrength, java.util.Collection<Unit> units, boolean attacking, boolean sea)
          Fill a List with units from the passed list up to maxStrength
static boolean hasLandRouteToEnemyOwnedCapitol(Territory t, PlayerID player, GameData data)
          true or false...does a land route exist from territory to any enemy owned capitol?
static float inviteBBEscort(Territory goTerr, float remainingStrengthNeeded, java.util.Collection<Unit> unitsAlreadyMoved, java.util.List<java.util.Collection<Unit>> moveUnits, java.util.List<Route> moveRoutes, GameData data, PlayerID player)
           
static float inviteBlitzAttack(boolean nonCombat, Territory enemy, float remainingStrengthNeeded, java.util.Collection<Unit> unitsAlreadyMoved, java.util.List<java.util.Collection<Unit>> moveUnits, java.util.List<Route> moveRoutes, GameData data, PlayerID player, boolean attacking, boolean forced)
          Look for possible blitzing units Currently restricts the territory to one to which there are no existing enemy units as neighbors unless forced Use forced to get units to blitz no matter what Should be modified to compare strength of source territory and its neighbors
static float inviteLandAttack(boolean nonCombat, Territory enemy, float remainingStrengthNeeded, java.util.Collection<Unit> unitsAlreadyMoved, java.util.List<java.util.Collection<Unit>> moveUnits, java.util.List<Route> moveRoutes, GameData data, PlayerID player, boolean attacking, boolean forced, java.util.List<Territory> alreadyAttacked)
          Look for possible land based Attack units Ignores blitzing
static float invitePlaneAttack(boolean noncombat, boolean fightersOnly, Territory target, float remainingStrengthNeeded, java.util.Collection<Unit> unitsAlreadyMoved, java.util.List<java.util.Collection<Unit>> moveUnits, java.util.List<Route> moveRoutes, GameData data, PlayerID player)
          Territory to which we want airplanes (maybe for an attack) if the target is on water, give preference to water based planes
static float inviteShipAttack(Territory eTerr, float remainingStrengthNeeded, java.util.Collection<Unit> unitsAlreadyMoved, java.util.List<java.util.Collection<Unit>> moveUnits, java.util.List<Route> moveRoutes, GameData data, PlayerID player, boolean attacking, boolean tFirst, boolean includeTransports)
          Invite Ship Attack to a certain sea territory (enemy) Air on a carrier will be included Transports will only be included if tFirst is true Units to be moved will be placed in moveUnits and routes in moveRoutes carrier & fighters will be moved as a single unit
static float inviteTransports(boolean noncombat, Territory target, float remainingStrengthNeeded, java.util.Collection<Unit> unitsAlreadyMoved, java.util.List<java.util.Collection<Unit>> moveUnits, java.util.List<Route> moveRoutes, GameData data, PlayerID player, boolean tFirst, boolean allowEnemy, java.util.List<Territory> seaTerrAttacked)
          Invite transports to bring units to this location
static java.util.Collection<Territory> islandCapitalTerritories(Territory startTerr, Territory targetTerr, GameData data)
          Return all land Territories which are within range between startTerr & targetTerr
static boolean isWaterAt(Territory checkTerr, GameData data)
          Does water exist around this territory
static Territory landAttackMap(GameData data, PlayerID player, java.util.HashMap<Territory,java.lang.Float> enemyMap)
          Prepares a map of the strength of every enemy land Territory Includes neutral if they are attackable
static boolean landRouteToEnemyCapital(Territory thisTerr, Route goRoute, GameData data, PlayerID player)
          determines the Land Route to a capital...returns if it exists and puts it in goRoute returns null for the Route if it does not exist
static boolean ListContainsOtherThanTransports(java.util.List<Unit> unitList)
          Determine if a list has something other than a transport Use for verifying sea attack
static java.util.List<Territory> possibleBlitzTerritories(Territory checkTerr, GameData data, PlayerID player)
          Build a list of territories that *could be* used by the enemy for blitzing Doesn't worry about whether blocking units are there or not
static int purchaseLoop(IntegerMap<java.lang.String> parameters, int ruleNum, IntegerMap<ProductionRule> bestAttack, IntegerMap<ProductionRule> bestDefense, IntegerMap<ProductionRule> bestTransport, IntegerMap<ProductionRule> bestMaxUnits, IntegerMap<ProductionRule> bestMobileAttack, java.util.HashMap<ProductionRule,java.lang.Boolean> transportMap, java.util.HashMap<ProductionRule,java.lang.Boolean> infMap, java.util.HashMap<ProductionRule,java.lang.Boolean> nonInfMap, java.util.HashMap<ProductionRule,java.lang.Boolean> supportableInfMap, GameData data, PlayerID player, int fighters)
          Recursive routine to determine the bestAttack and bestDefense set of purchase Expects bestAttack to already be filled with the rules
static boolean quickBattleEstimator(IntegerMap<UnitType> attacker, IntegerMap<UnitType> defender, PlayerID aPlayer, PlayerID dPlayer, boolean sea, boolean subRestricted)
          Very basic estimation of battle through recursion Determine pips on dice and divide by 6 to get hits Remove weakest attackers/defenders TODO: fix battleEstimator for ships
static java.util.HashMap<Territory,java.lang.Float> rankAmphibReinforcementTerritories(GameData data, java.util.List<Territory> ignoreTerr, PlayerID player, boolean tFirst)
          Target Territories for amphibious non-combat movement No Islands will result
static java.util.HashMap<Territory,java.lang.Float> rankTerritories(GameData data, java.util.List<Territory> ourFriendlyTerr, java.util.List<Territory> ourEnemyTerr, java.util.List<Territory> ignoreTerr, PlayerID player, boolean tFirst, boolean waterBased, boolean nonCombat)
          Territory ranking system
static void removeNonAmphibTerritories(java.util.List<Territory> territories, GameData data)
          Remove any territories which cannot be amphibiously invaded
static IntegerMap<UnitType> removeUnits(IntegerMap<UnitType> units, boolean attacking, int killNum, PlayerID player, boolean sea)
          Method for removing a set of units from an IntegerMap of units Major Assumption: Cost Increases: infantry < artillery < armour If Ship is passed through in a land attack it is removed
static void removeUnthreatenedTerritories(GameData data, PlayerID player, java.util.List<Territory> terrList)
          Remove enemy territories, territories which have no threat and no enemy land neighbor
static void reorder(java.util.List<?> reorder, IntegerMap map, boolean greaterThan)
           
static void reorder(java.util.List<?> reorder, java.util.Map<?,? extends java.lang.Number> map, boolean greaterThan)
           
static Route repairRoute(java.util.Collection<Unit> moveUnits, Route moveRoute, GameData data, PlayerID player)
          Verify an individual move - Route exists (not null) and there is an endpoint
static boolean RouteHasNoWater(Route testRoute)
          Does this Route contain water anywhere Differs from route.crossesWater in that it checks the beginning and end
static int shipThreatToTerr(Territory checkTerr, GameData data, PlayerID player, boolean tFirst)
          Determine how many more ships the enemy has than the player fighters on AC are counted also Each ship is given the same value except for BB (two) Transports are treated as 0.5 if tFirst and 0 if not TODO: Add land based fighters and bombers to this list
static java.util.List<Unit> sortTransportUnits(java.util.List<Unit> transUnits)
          Interleave infantry and artillery/armor for loading on transports
static float strength(java.util.Collection<Unit> units, boolean attacking, boolean sea, boolean transportsFirst)
          Get a quick and dirty estimate of the strength of some units in a battle.
static float strengthOfTerritory(GameData data, Territory thisTerr, PlayerID player, boolean attacking, boolean sea, boolean tFirst, boolean allied)
          Determine the strength of a territory
static float strengthOnContinent(GameData data, PlayerID player, Territory continentTerr)
          Return a players allied strength on the entire continent
static java.util.List<Territory> stripLandLockedTerr(GameData data, java.util.List<Territory> allTerr)
          Returns a List of all territories with a water neighbor
static IntegerMap<Territory> targetTerritories(GameData data, PlayerID player, int tDistance)
          Look for a set of target Territories based from factories Return Map of these with their production values Islands are considered up to a distance of 5
static boolean territoryHasThreatenedAlliedFactoryNeighbor(GameData data, Territory eTerr, PlayerID player)
          Is the territory a neighbor of an allied factory and is that factory threatened?
static Match<Territory> TerritoryIsImpassableToAirUnits(GameData data)
          Assumes that water is passable to air units always
static Match<Territory> TerritoryIsNotImpassableToAirUnits(GameData data)
           
static java.util.List<Territory> TerritoryOnlyPlanes(GameData data, PlayerID player)
          Finds a list of territories which contain airUnits, but don't have land Units
static boolean threatToAlliedCapitals(GameData data, PlayerID player, java.util.List<Territory> threats, boolean tFirst)
          determine the threat to the capital of the player's allies returns boolean true or false whether threat exists returns capitals threatened in threats
static void trimTerritoryList(java.util.List<Territory> xTerrList, int maxNum)
          Trim a list of territories to a maximum number If the list has fewer entries than max number, nothing is done
static float twoAwayStrengthNotCounted(GameData data, PlayerID player, Territory eTerr)
           
static float uStrength(Unit units, boolean attacking, boolean sea, boolean transportsFirst)
          Determine the strength of a single unit
static void verifyMoves(java.util.List<java.util.Collection<Unit>> moveUnits, java.util.List<Route> moveRoutes, GameData data, PlayerID player)
          Verifies an entire set of moves 1st: Repair routes that are invalid 2nd: Remove transport only attacks
static float verifyPlaneAttack(GameData data, java.util.List<java.util.Collection<Unit>> xMoveUnits, java.util.List<Route> xMoveRoutes, PlayerID player, java.util.List<Territory> alreadyAttacked)
          Look through a list and find planes do not have a good landing point available TODO: Analyze and determine when our units have evacuated the landing points to make an attack
static java.util.Collection<Unit> whatPlanesNeedToLand(boolean doBombers, Territory thisTerritory, PlayerID player)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SUtils

public SUtils()
Method Detail

threatToAlliedCapitals

public static boolean threatToAlliedCapitals(GameData data,
                                             PlayerID player,
                                             java.util.List<Territory> threats,
                                             boolean tFirst)
determine the threat to the capital of the player's allies returns boolean true or false whether threat exists returns capitals threatened in threats


stripLandLockedTerr

public static java.util.List<Territory> stripLandLockedTerr(GameData data,
                                                            java.util.List<Territory> allTerr)
Returns a List of all territories with a water neighbor

Parameters:
data -
allTerr - - List of Territories
Returns:

bomberTerrInList

public static java.util.Collection<Territory> bomberTerrInList(java.util.List<java.util.Collection<Unit>> units,
                                                               java.util.List<Route> routes)
Determine if a List has any bombers in it

Parameters:
units -
Returns:

landAttackMap

public static Territory landAttackMap(GameData data,
                                      PlayerID player,
                                      java.util.HashMap<Territory,java.lang.Float> enemyMap)
Prepares a map of the strength of every enemy land Territory Includes neutral if they are attackable

Parameters:
data -
player -
enemyMap -
Returns:

TerritoryIsImpassableToAirUnits

public static Match<Territory> TerritoryIsImpassableToAirUnits(GameData data)
Assumes that water is passable to air units always

Parameters:
data -
Returns:

TerritoryIsNotImpassableToAirUnits

public static final Match<Territory> TerritoryIsNotImpassableToAirUnits(GameData data)

continentAlliedUnitTerr

public static void continentAlliedUnitTerr(GameData data,
                                           PlayerID player,
                                           Territory startTerr,
                                           java.util.List<Territory> contiguousTerr,
                                           java.util.List<Territory> ignoreTerr)
Return a list of Territories on a Continent which are allied

Parameters:
data -
player -
startTerr -
contiguousTerr - - actual list to be created
ignoreTerr - - cannot be null (should be an empty List) - Add Territories here to ignore them

strengthOnContinent

public static float strengthOnContinent(GameData data,
                                        PlayerID player,
                                        Territory continentTerr)
Return a players allied strength on the entire continent

Parameters:
data -
player -
continentTerr -
Returns:

removeUnthreatenedTerritories

public static void removeUnthreatenedTerritories(GameData data,
                                                 PlayerID player,
                                                 java.util.List<Territory> terrList)
Remove enemy territories, territories which have no threat and no enemy land neighbor

Parameters:
data -
player -
terrList -

breakUnitsBySpeed

public static void breakUnitsBySpeed(java.util.List<java.util.Collection<Unit>> returnUnits,
                                     GameData data,
                                     PlayerID player,
                                     java.util.List<Unit> units)
Create a List which contains a series of collections each which has a different movement

Parameters:
returnUnits -
data -
player -
units -

targetTerritories

public static IntegerMap<Territory> targetTerritories(GameData data,
                                                      PlayerID player,
                                                      int tDistance)
Look for a set of target Territories based from factories Return Map of these with their production values Islands are considered up to a distance of 5

Parameters:
data -
player -
Returns:

sortTransportUnits

public static java.util.List<Unit> sortTransportUnits(java.util.List<Unit> transUnits)
Interleave infantry and artillery/armor for loading on transports


getPlayerCostMap

public static java.util.HashMap<PlayerID,IntegerMap<UnitType>> getPlayerCostMap(GameData data)
Generate HashMap of the costs of all players


trimTerritoryList

public static void trimTerritoryList(java.util.List<Territory> xTerrList,
                                     int maxNum)
Trim a list of territories to a maximum number If the list has fewer entries than max number, nothing is done

Parameters:
xTerrList -
maxNum - - maxNum of entries

evaluateNonCombat

public static int evaluateNonCombat(int numMoves,
                                    int evalDistance,
                                    java.util.HashMap<java.lang.Integer,java.util.HashMap<Territory,java.lang.Float>> reinforcedTerrList,
                                    java.util.HashMap<java.lang.Integer,IntegerMap<Territory>> unitCountList,
                                    PlayerID player,
                                    GameData data,
                                    boolean tFirst)

getPlayerTUV

public static IntegerMap<PlayerID> getPlayerTUV(GameData data)
Determine the current TUV strength of all players

Returns:
IntegerMap - contains TUV of each player

islandCapitalTerritories

public static java.util.Collection<Territory> islandCapitalTerritories(Territory startTerr,
                                                                       Territory targetTerr,
                                                                       GameData data)
Return all land Territories which are within range between startTerr & targetTerr

Parameters:
startTerr -
targetTerr -
data -
Returns:

closestAmphibAlliedTerritory

public static Territory closestAmphibAlliedTerritory(Territory startTerr,
                                                     Territory targetTerr,
                                                     java.util.List<Territory> contiguousTerritories,
                                                     GameData data,
                                                     PlayerID player,
                                                     boolean tFirst)
Return the closest allied Territory to targetTerr Creates a list of the top 3 closest points and then returns the one with the maximum # of units Always returns a neighbor of startTerr if the neighbor is in the top 3

Parameters:
startTerr -
targetTerr -
data -
contiguousTerritories - - Set of 3 potential landing points
player -
tFirst -
Returns:

closestEnemyCapital

public static Territory closestEnemyCapital(Territory startTerr,
                                            GameData data,
                                            PlayerID player)
Find enemyCapital closest to startTerr

Parameters:
startTerr -
data -
player -
Returns:

calculateTUVDifference

public static boolean calculateTUVDifference(Territory eTerr,
                                             java.util.Collection<Unit> invasionUnits,
                                             java.util.Collection<Unit> defenderUnits,
                                             java.util.HashMap<PlayerID,IntegerMap<UnitType>> costMap,
                                             PlayerID player,
                                             GameData data,
                                             boolean aggressive,
                                             boolean subRestricted)

determineTUV

public static int determineTUV(IntegerMap<UnitType> unitList,
                               IntegerMap<UnitType> unitCost)

getNeighboringEnemyLandTerritories

public static java.util.List<Territory> getNeighboringEnemyLandTerritories(GameData data,
                                                                           PlayerID player)
All the territories that border one of our territories


getTerritoriesWithEnemyNeighbor

public static java.util.List<Territory> getTerritoriesWithEnemyNeighbor(GameData data,
                                                                        PlayerID player,
                                                                        boolean allied,
                                                                        boolean neutral)
All allied Territories which have a Land Enemy Neighbor


getNeighboringEnemyLandTerritories

public static java.util.List<Territory> getNeighboringEnemyLandTerritories(GameData data,
                                                                           PlayerID player,
                                                                           boolean allied)
All territories that border our terr or allied terr boolean allied - search for enemies of allied territories, not just owned


getNeighboringNeutralLandTerritories

public static java.util.List<Territory> getNeighboringNeutralLandTerritories(GameData data,
                                                                             PlayerID player,
                                                                             boolean allied)
All neutral territories that border our terr or allied terr boolean allied - search for neutral near allied territories, not just owned


getClosestWaterTerr

public static Territory getClosestWaterTerr(Territory target,
                                            Territory source,
                                            GameData data,
                                            PlayerID player,
                                            boolean allowEnemy)
find the water terr next to target which is closest to the source target: land destination source: present location minDist: actual distance from source to resulting water terr Returns null if target has no water territories


getSafestWaterTerr

public static Territory getSafestWaterTerr(Territory target,
                                           Territory source,
                                           java.util.List<Territory> ignoreTerr,
                                           GameData data,
                                           PlayerID player,
                                           boolean allowEnemy,
                                           boolean tFirst)

possibleBlitzTerritories

public static java.util.List<Territory> possibleBlitzTerritories(Territory checkTerr,
                                                                 GameData data,
                                                                 PlayerID player)
Build a list of territories that *could be* used by the enemy for blitzing Doesn't worry about whether blocking units are there or not

Parameters:
checkTerr - - Territory which enemy would blitz
data -
player -
Returns:

getNeighboringEnemyLandTerritories

public static java.util.List<Territory> getNeighboringEnemyLandTerritories(GameData data,
                                                                           PlayerID player,
                                                                           Territory check)
All the territories that border a certain territory


getNeighboringLandTerritories

public static java.util.List<Territory> getNeighboringLandTerritories(GameData data,
                                                                      PlayerID player,
                                                                      Territory check)
All Allied Territories which neighbor a territory This duplicates getNeighbors(check, Matches.isTerritoryAllied(player, data))


doesLandExistAt

public static boolean doesLandExistAt(Territory t,
                                      GameData data,
                                      boolean neutral)
Does this territory have any land? i.e. it isn't an island

Returns:
boolean (true if a land territory is a neighbor to t

distanceToEnemy

public static int distanceToEnemy(Territory t,
                                  java.util.List<Territory> beenThere,
                                  GameData data,
                                  PlayerID player,
                                  boolean sea)
Recursive routine for finding the distance to an enemy

Parameters:
t -
beenThere - - list of territories already checked
data -
player -
Returns:
int of distance to enemy

getEnemyCapitals

public static java.util.List<Territory> getEnemyCapitals(GameData data,
                                                         PlayerID player)
List containing the enemy Capitals


getEnemyPlayers

public static java.util.List<PlayerID> getEnemyPlayers(GameData data,
                                                       PlayerID player)
Returns a list of all enemy players

Parameters:
data -
player -
Returns:
List enemyPlayers

getAlliedLandTerrNextToEnemyCapital

public static Territory getAlliedLandTerrNextToEnemyCapital(int minDist,
                                                            Territory capTerr,
                                                            Territory fromTerr,
                                                            GameData data,
                                                            PlayerID player)
Looking for the closest land territory next to an enemy capital which is owned by an ally Use this for dumping units from transports

Returns:
- Land Territory with allied units

landRouteToEnemyCapital

public static boolean landRouteToEnemyCapital(Territory thisTerr,
                                              Route goRoute,
                                              GameData data,
                                              PlayerID player)
determines the Land Route to a capital...returns if it exists and puts it in goRoute returns null for the Route if it does not exist

Parameters:
thisTerr - - Territory to be checked
goRoute - - contains the actual route
Returns:
- true if the route exists, false if it doesn't exist

getUnitsUpToStrength

public static java.util.List<Unit> getUnitsUpToStrength(double maxStrength,
                                                        java.util.Collection<Unit> units,
                                                        boolean attacking,
                                                        boolean sea)
Fill a List with units from the passed list up to maxStrength


TerritoryOnlyPlanes

public static java.util.List<Territory> TerritoryOnlyPlanes(GameData data,
                                                            PlayerID player)
Finds a list of territories which contain airUnits, but don't have land Units

Returns:
List of Territories

findNearestMaxUnits

public static Territory findNearestMaxUnits(PlayerID player,
                                            GameData data,
                                            Territory t,
                                            boolean friendly)
Finds the Territory within 3 Territories which has a maximum # of units Uses friendly to determine if we are looking for our guys or enemy Returns Territory with a maximum # of units (enemy or friendly)


whatPlanesNeedToLand

public static java.util.Collection<Unit> whatPlanesNeedToLand(boolean doBombers,
                                                              Territory thisTerritory,
                                                              PlayerID player)

getStrengthOfPotentialAttackers

public static float getStrengthOfPotentialAttackers(Territory location,
                                                    GameData data,
                                                    PlayerID player,
                                                    boolean tFirst,
                                                    boolean ignoreOnlyPlanes,
                                                    java.util.List<Territory> ignoreTerr)
Returns the strength of all attackers to a territory differentiates between sea and land attack determines all transports within range of territory determines all air units within range of territory (using 2 for fighters and 3 for bombers) does not check for extended range fighters or bombers

Parameters:
tFirst - - can transports be killed before other sea units
ignoreOnlyPlanes - - if true, returns 0.0F if only planes can attack the territory

findOurShips

public static java.util.List<Territory> findOurShips(Territory t,
                                                     GameData data,
                                                     PlayerID player)
Returns all Territories which contain Allied Units within a radius of 4 Territories of t Works for land units as well as ships

Returns:

findOurShips

public static java.util.List<Territory> findOurShips(Territory t,
                                                     GameData data,
                                                     PlayerID player,
                                                     Match<Unit> unitCondition)
Returns a list of Territories containing Allied Ships within a radius of 3 which meet the condition

Parameters:
unitCondition - - Match condition
Returns:
- List of Territories - works ships or land units

findOnlyMyShips

public static java.util.List<Territory> findOnlyMyShips(Territory t,
                                                        GameData data,
                                                        PlayerID player,
                                                        Match<Unit> unitCondition)
Identical to findOurShips...just owned rather than allied Could be merged with findOurShips with a boolean for allied Finds all units within 3 Territories of t which match unitCondition returns the List


findCertainShips

public static java.util.List<Territory> findCertainShips(GameData data,
                                                         PlayerID player,
                                                         Match<Unit> unitCondition)
Return All Territories containing a Certain Owned Unit (Land, Sea or Air) specified by unitCondition

Returns:
List of Territories

findUnitTerr

public static java.util.List<Territory> findUnitTerr(GameData data,
                                                     PlayerID player,
                                                     Match<Unit> unitCondition)
Return Territories containing any unit depending on unitCondition Differs from findCertainShips because it doesn't require the units be owned


findOurPlanes

public static java.util.List<Territory> findOurPlanes(Territory t,
                                                      GameData data,
                                                      PlayerID player)
Returns list of territories within 4 territories of t and contain owned planes


findUnits

public static java.util.List<Territory> findUnits(Territory t,
                                                  GameData data,
                                                  Match<Unit> unitCondition,
                                                  int maxDist)
Returns a list of territories within maxDist which meat the requirement of unitCondition No requirements of ownership or allied units

Returns:

allOurTerritories

public static java.util.List<Territory> allOurTerritories(GameData data,
                                                          PlayerID player)
Territories we actually own in a modifiable List


allAlliedTerritories

public static java.util.List<Territory> allAlliedTerritories(GameData data,
                                                             PlayerID player)
All Allied TErritories in a modifiable List


allEnemyTerritories

public static java.util.List<Territory> allEnemyTerritories(GameData data,
                                                            PlayerID player)
All Enemy Territories in a modifiable List


findNearest

public static Route findNearest(Territory start,
                                Match<Territory> endCondition,
                                Match<Territory> routeCondition,
                                GameData data)
Find the Route to the nearest Territory

Parameters:
start - - starting territory
endCondition - - condition for the ending Territory
routeCondition - - condition for each Territory in Route
data -
Returns:

findNearestMaxContaining

public static Route findNearestMaxContaining(Territory start,
                                             Match<Territory> endCondition,
                                             Match<Territory> routeCondition,
                                             Match<Unit> unitCondition,
                                             int maxUnits,
                                             GameData data)
Find Route from start to a Territory having endCondition which has a maximum of a certain set of Units (unitCondition)

Parameters:
start - - initial territory
endCondition - - final territory must match this
routeCondition - - all territories on route must match this
unitCondition - - units must match this
maxUnits - - how many units were found there
Returns:
- Route to the endCondition

findNearestNotEmpty

public static Route findNearestNotEmpty(Territory start,
                                        Match<Territory> endCondition,
                                        Match<Territory> routeCondition,
                                        GameData data)

hasLandRouteToEnemyOwnedCapitol

public static boolean hasLandRouteToEnemyOwnedCapitol(Territory t,
                                                      PlayerID player,
                                                      GameData data)
true or false...does a land route exist from territory to any enemy owned capitol?


airUnitIsLandableOnCarrier

public static boolean airUnitIsLandableOnCarrier(Unit u,
                                                 Territory source,
                                                 Territory target,
                                                 PlayerID player,
                                                 GameData data)

airUnitIsLandable

public static boolean airUnitIsLandable(Unit u,
                                        Territory source,
                                        Territory target,
                                        PlayerID owner,
                                        GameData data)

ACTerritory

public static java.util.List<Territory> ACTerritory(PlayerID player,
                                                    GameData data)
Returns a list of all territories containing owned AirCraft Carriers


addUnitCollection

public static void addUnitCollection(java.util.List<java.util.Collection<Unit>> aUnits,
                                     java.util.Collection<Unit> bUnits)

airstrength

public static float airstrength(Unit airunit,
                                boolean attacking)
Determine the available strength of a single air unit Primarily useful for a sea battle needing support Moved from AIUtils to improve portability with changes by others


allairstrength

public static float allairstrength(java.util.Collection<Unit> units,
                                   boolean attacking)
Determine the strength of a collection of airUnits


uStrength

public static float uStrength(Unit units,
                              boolean attacking,
                              boolean sea,
                              boolean transportsFirst)
Determine the strength of a single unit


strength

public static float strength(java.util.Collection<Unit> units,
                             boolean attacking,
                             boolean sea,
                             boolean transportsFirst)
Get a quick and dirty estimate of the strength of some units in a battle.

Parameters:
units - - the units to measure
attacking - - are the units on attack or defense
sea - - calculate the strength of the units in a sea or land battle?
Returns:

findFactoryTerritory

public static Territory findFactoryTerritory(GameData data,
                                             PlayerID player,
                                             float risk,
                                             boolean buyfactory,
                                             boolean onWater)
determines a suitable Territory for a factory suitable: At Least 2 PU All Territories around it are owned Strength of Units in the Territory and 1 Territory away Is greater than the sum of all enemy Territory 2 away Territory should be closest to an enemy Capital

Parameters:
data -
player -
risk - - not really used...should pass a relative risk back
buyfactory -
Returns:

getExactNeighbors

public static java.util.List<Territory> getExactNeighbors(Territory territory,
                                                          int distance,
                                                          PlayerID player,
                                                          boolean neutral)
Gets the neighbors which are exactly a certain # of territories away (distance) Removes the inner circle neighbors neutral - whether to include neutral countries


RouteHasNoWater

public static boolean RouteHasNoWater(Route testRoute)
Does this Route contain water anywhere Differs from route.crossesWater in that it checks the beginning and end

Parameters:
testRoute -
Returns:
- true if water does not exist...false if water does exist

findASeaTerritoryToPlaceOn

public static Territory findASeaTerritoryToPlaceOn(Territory landTerr,
                                                   GameData data,
                                                   PlayerID player,
                                                   boolean tFirst)
Look for an available sea Territory to place sea Units if other owned sea units exist, place them with these units Otherwise, look for the location which is least likely to get them killed

Parameters:
landTerr - - factory territory
tFirst - - can transports be killed during battle Should be modified to include the list of units which will be dropped (for strength measurement)

inviteBBEscort

public static float inviteBBEscort(Territory goTerr,
                                   float remainingStrengthNeeded,
                                   java.util.Collection<Unit> unitsAlreadyMoved,
                                   java.util.List<java.util.Collection<Unit>> moveUnits,
                                   java.util.List<Route> moveRoutes,
                                   GameData data,
                                   PlayerID player)

inviteShipAttack

public static float inviteShipAttack(Territory eTerr,
                                     float remainingStrengthNeeded,
                                     java.util.Collection<Unit> unitsAlreadyMoved,
                                     java.util.List<java.util.Collection<Unit>> moveUnits,
                                     java.util.List<Route> moveRoutes,
                                     GameData data,
                                     PlayerID player,
                                     boolean attacking,
                                     boolean tFirst,
                                     boolean includeTransports)
Invite Ship Attack to a certain sea territory (enemy) Air on a carrier will be included Transports will only be included if tFirst is true Units to be moved will be placed in moveUnits and routes in moveRoutes carrier & fighters will be moved as a single unit


inviteTransports

public static float inviteTransports(boolean noncombat,
                                     Territory target,
                                     float remainingStrengthNeeded,
                                     java.util.Collection<Unit> unitsAlreadyMoved,
                                     java.util.List<java.util.Collection<Unit>> moveUnits,
                                     java.util.List<Route> moveRoutes,
                                     GameData data,
                                     PlayerID player,
                                     boolean tFirst,
                                     boolean allowEnemy,
                                     java.util.List<Territory> seaTerrAttacked)
Invite transports to bring units to this location

Parameters:
noncombat - - is this in noncombat
target - - Land Territory needing units
remainingStrengthNeeded - - how many units we needed moved to this location
unitsAlreadyMoved - - List of Units which is not available for further movement

invitePlaneAttack

public static float invitePlaneAttack(boolean noncombat,
                                      boolean fightersOnly,
                                      Territory target,
                                      float remainingStrengthNeeded,
                                      java.util.Collection<Unit> unitsAlreadyMoved,
                                      java.util.List<java.util.Collection<Unit>> moveUnits,
                                      java.util.List<Route> moveRoutes,
                                      GameData data,
                                      PlayerID player)
Territory to which we want airplanes (maybe for an attack) if the target is on water, give preference to water based planes

Parameters:
noncombat -
fightersOnly - - ignore anything that cannot land on AC
withCarrier - - fighters on Carriers are accompanied by carrier
target - - target territory
remainingStrengthNeeded - - use to determine how many to bring
unitsAlreadyMoved - - Units not available for further movement

inviteLandAttack

public static float inviteLandAttack(boolean nonCombat,
                                     Territory enemy,
                                     float remainingStrengthNeeded,
                                     java.util.Collection<Unit> unitsAlreadyMoved,
                                     java.util.List<java.util.Collection<Unit>> moveUnits,
                                     java.util.List<Route> moveRoutes,
                                     GameData data,
                                     PlayerID player,
                                     boolean attacking,
                                     boolean forced,
                                     java.util.List<Territory> alreadyAttacked)
Look for possible land based Attack units Ignores blitzing

Parameters:
enemy - - territory to be invaded
remainingStrengthNeeded - - total strength of units needed - stop adding when this reaches 0.0

inviteBlitzAttack

public static float inviteBlitzAttack(boolean nonCombat,
                                      Territory enemy,
                                      float remainingStrengthNeeded,
                                      java.util.Collection<Unit> unitsAlreadyMoved,
                                      java.util.List<java.util.Collection<Unit>> moveUnits,
                                      java.util.List<Route> moveRoutes,
                                      GameData data,
                                      PlayerID player,
                                      boolean attacking,
                                      boolean forced)
Look for possible blitzing units Currently restricts the territory to one to which there are no existing enemy units as neighbors unless forced Use forced to get units to blitz no matter what Should be modified to compare strength of source territory and its neighbors


closestToEnemyCapital

public static Territory closestToEnemyCapital(java.util.List<Territory> ourTerr,
                                              GameData data,
                                              PlayerID player,
                                              boolean byLand)
Takes a List of territories and finds the one closest to an enemy capitol by Land

Parameters:
ourTerr -
byLand - - force the route to be traced by Land
Returns:
Territory closest or null if none has a land route

getTwoRoute

public static Route getTwoRoute(Territory t1,
                                Territory t2,
                                Match<Territory> condition,
                                java.util.List<Territory> blockedTerr,
                                GameData data)
Make a two step route in which the condition only applies to the middle territory in the route and not the target

Parameters:
blockedTerr - - List of Territories the route cannot pass through

determineEnemyBlitzStrength

public static float determineEnemyBlitzStrength(Territory blitzHere,
                                                java.util.List<Route> blitzTerrRoutes,
                                                java.util.List<Territory> blockTerr,
                                                GameData data,
                                                PlayerID ePlayer)
Determine the enemy potential for blitzing a territory - all enemies are combined

Parameters:
blitzHere - - Territory expecting to be blitzed
blitzTerr - - Territory which is being blitzed through (not guaranteed to be all possible route territories!)
data -
ePlayer - - the enemy Player
Returns:
actual strength of enemy units (armor)

ListContainsOtherThanTransports

public static boolean ListContainsOtherThanTransports(java.util.List<Unit> unitList)
Determine if a list has something other than a transport Use for verifying sea attack

Parameters:
unitList - - List of units
Returns:
true - has a non-transport unit

verifyMoves

public static void verifyMoves(java.util.List<java.util.Collection<Unit>> moveUnits,
                               java.util.List<Route> moveRoutes,
                               GameData data,
                               PlayerID player)
Verifies an entire set of moves 1st: Repair routes that are invalid 2nd: Remove transport only attacks

Parameters:
moveUnits -
moveRoutes -
data -
player -

repairRoute

public static Route repairRoute(java.util.Collection<Unit> moveUnits,
                                Route moveRoute,
                                GameData data,
                                PlayerID player)
Verify an individual move - Route exists (not null) and there is an endpoint

Parameters:
moveUnits -
moveRoute -
Returns:
- new Route which allows for movement or null if Move is valid

isWaterAt

public static boolean isWaterAt(Territory checkTerr,
                                GameData data)
Does water exist around this territory

Parameters:
checkTerr -
Returns:
true if water exists, false if it doesn't

convertListToMap

public static IntegerMap<UnitType> convertListToMap(java.util.Collection<Unit> units)
Map a list of units

Parameters:
units -
Returns:

quickBattleEstimator

public static boolean quickBattleEstimator(IntegerMap<UnitType> attacker,
                                           IntegerMap<UnitType> defender,
                                           PlayerID aPlayer,
                                           PlayerID dPlayer,
                                           boolean sea,
                                           boolean subRestricted)
Very basic estimation of battle through recursion Determine pips on dice and divide by 6 to get hits Remove weakest attackers/defenders TODO: fix battleEstimator for ships

Parameters:
attacker - - IntegerMap of number of attacking units (returns adjusted #s)
defender - - IntegerMap of number of defending units
Returns:
- true if Attacker probably wins

strengthOfTerritory

public static float strengthOfTerritory(GameData data,
                                        Territory thisTerr,
                                        PlayerID player,
                                        boolean attacking,
                                        boolean sea,
                                        boolean tFirst,
                                        boolean allied)
Determine the strength of a territory

Parameters:
data -
thisTerr -
player -
attacking - - attacking strength or defending
sea -
tFirst -
allied - - allied = true - all allied units --> false - owned units only
Returns:

verifyPlaneAttack

public static float verifyPlaneAttack(GameData data,
                                      java.util.List<java.util.Collection<Unit>> xMoveUnits,
                                      java.util.List<Route> xMoveRoutes,
                                      PlayerID player,
                                      java.util.List<Territory> alreadyAttacked)
Look through a list and find planes do not have a good landing point available TODO: Analyze and determine when our units have evacuated the landing points to make an attack

Parameters:
data -
xMoveUnits -
xMoveRoutes -
player -
alreadyAttacked -
Returns:

removeUnits

public static IntegerMap<UnitType> removeUnits(IntegerMap<UnitType> units,
                                               boolean attacking,
                                               int killNum,
                                               PlayerID player,
                                               boolean sea)
Method for removing a set of units from an IntegerMap of units Major Assumption: Cost Increases: infantry < artillery < armour If Ship is passed through in a land attack it is removed

Parameters:
units - - Units and #
attacking -
killNum - - # of units to kill
Returns:

shipThreatToTerr

public static int shipThreatToTerr(Territory checkTerr,
                                   GameData data,
                                   PlayerID player,
                                   boolean tFirst)
Determine how many more ships the enemy has than the player fighters on AC are counted also Each ship is given the same value except for BB (two) Transports are treated as 0.5 if tFirst and 0 if not TODO: Add land based fighters and bombers to this list

Parameters:
checkTerr - - territory to be checked
data -
player -
attackAdv - - total advantage the enemy has
tFirst - - can transports be killed before other units
Returns:

removeNonAmphibTerritories

public static void removeNonAmphibTerritories(java.util.List<Territory> territories,
                                              GameData data)
Remove any territories which cannot be amphibiously invaded

Parameters:
territories -
data -

reorder

public static void reorder(java.util.List<?> reorder,
                           IntegerMap map,
                           boolean greaterThan)

reorder

public static void reorder(java.util.List<?> reorder,
                           java.util.Map<?,? extends java.lang.Number> map,
                           boolean greaterThan)

findPurchaseMix

public static boolean findPurchaseMix(IntegerMap<ProductionRule> bestAttack,
                                      IntegerMap<ProductionRule> bestDefense,
                                      IntegerMap<ProductionRule> bestTransport,
                                      IntegerMap<ProductionRule> bestMaxUnits,
                                      IntegerMap<ProductionRule> bestMobileAttack,
                                      java.util.List<ProductionRule> rules,
                                      int totPU,
                                      int maxUnits,
                                      GameData data,
                                      PlayerID player,
                                      int fighters)
Take the mix of Production Rules and determine the best purchase set for attack, defense or transport So much more that can be done with this...track units and try to minimize or maximize the # purchased


purchaseLoop

public static int purchaseLoop(IntegerMap<java.lang.String> parameters,
                               int ruleNum,
                               IntegerMap<ProductionRule> bestAttack,
                               IntegerMap<ProductionRule> bestDefense,
                               IntegerMap<ProductionRule> bestTransport,
                               IntegerMap<ProductionRule> bestMaxUnits,
                               IntegerMap<ProductionRule> bestMobileAttack,
                               java.util.HashMap<ProductionRule,java.lang.Boolean> transportMap,
                               java.util.HashMap<ProductionRule,java.lang.Boolean> infMap,
                               java.util.HashMap<ProductionRule,java.lang.Boolean> nonInfMap,
                               java.util.HashMap<ProductionRule,java.lang.Boolean> supportableInfMap,
                               GameData data,
                               PlayerID player,
                               int fighters)
Recursive routine to determine the bestAttack and bestDefense set of purchase Expects bestAttack to already be filled with the rules

Parameters:
parameters - - set of parameters to be used (8 of them)
ruleNum - - which rule should the routine use
bestAttack - - list of the rules and the number to be purchased (optimized for attack)
bestDefense - - list of the rules and the number to be purchased (optimized for defense)
bestTransport - - list of the rules and the number to be purchased (optimized for transporting)
bestMaxUnits - - list of the rules and the number to be purchased (optimized for attack and max units)
bestTransport - - list of the rules and the number to be purchased (optimized for transport)
Returns:
- integer which is 1 if bestAttack has changed, 2 if bestDefense has changed, 3 if both have changed

getAlliedPlayers

public static java.util.List<PlayerID> getAlliedPlayers(GameData data,
                                                        PlayerID player)

determineAggressiveAttack

public static boolean determineAggressiveAttack(GameData data,
                                                PlayerID player,
                                                float aggressiveFactor)
use TUV for a set of allies and their enemies to determine if TUV superiority indicates that a player can be more aggressive in an attack.

Parameters:
data -
player -
aggressiveFactor - - float which will set how much more TUV is needed to allow aggressive
Returns:

getAlliedEnemyTUV

public static int getAlliedEnemyTUV(GameData data,
                                    PlayerID player,
                                    boolean allied)
Determine TUV for allies/enemies

Parameters:
data -
player -
allied - - boolean indicating for which set to gather TUV
Returns:

getMaxSeaRoute

public static Route getMaxSeaRoute(GameData data,
                                   Territory start,
                                   Territory destination,
                                   PlayerID player,
                                   boolean attacking,
                                   int maxDistance)

getLeftToSpend

public static int getLeftToSpend(GameData data,
                                 PlayerID player)
Returns the players current pus available

Parameters:
data -
player -
Returns:

territoryHasThreatenedAlliedFactoryNeighbor

public static boolean territoryHasThreatenedAlliedFactoryNeighbor(GameData data,
                                                                  Territory eTerr,
                                                                  PlayerID player)
Is the territory a neighbor of an allied factory and is that factory threatened? Add in 50% of the factory's allied territory's strength + 100% of the strength of the factory territory

Parameters:
data -
eTerr -
player -
Returns:

rankTerritories

public static java.util.HashMap<Territory,java.lang.Float> rankTerritories(GameData data,
                                                                           java.util.List<Territory> ourFriendlyTerr,
                                                                           java.util.List<Territory> ourEnemyTerr,
                                                                           java.util.List<Territory> ignoreTerr,
                                                                           PlayerID player,
                                                                           boolean tFirst,
                                                                           boolean waterBased,
                                                                           boolean nonCombat)
Territory ranking system

Parameters:
data -
ourFriendlyTerr -
ourEnemyTerr -
player -
tFirst -
waterBased - - attack is Water Based - Remove all terr with no avail water
nonCombat - - if nonCombat, emphasize threatened factories over their neighbors
Returns:
HashMap ranking of Territories

twoAwayStrengthNotCounted

public static float twoAwayStrengthNotCounted(GameData data,
                                              PlayerID player,
                                              Territory eTerr)

rankAmphibReinforcementTerritories

public static java.util.HashMap<Territory,java.lang.Float> rankAmphibReinforcementTerritories(GameData data,
                                                                                              java.util.List<Territory> ignoreTerr,
                                                                                              PlayerID player,
                                                                                              boolean tFirst)
Target Territories for amphibious non-combat movement No Islands will result

Parameters:
data -
ignoreTerr -
player -
tFirst -
nonCombat -
Returns: