games.strategy.triplea.baseAI
Class AIUtils

java.lang.Object
  extended by games.strategy.triplea.baseAI.AIUtils

public class AIUtils
extends java.lang.Object

Handy utility methods for the writers of an AI.

Author:
sgb

Constructor Summary
AIUtils()
           
 
Method Summary
static int getCost(UnitType unitType, PlayerID player, GameData data)
          How many PU's does it cost the given player to produce the given unit type.
static java.util.Comparator<Unit> getCostComparator()
           
static ProductionRule getProductionRule(UnitType unitType, PlayerID player, GameData data)
          Get the production rule for the given player, for the given unit type.
static float strength(java.util.Collection<Unit> units, boolean attacking, boolean sea)
          Get a quick and dirty estimate of the strength of some units in a battle.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AIUtils

public AIUtils()
Method Detail

getCost

public static int getCost(UnitType unitType,
                          PlayerID player,
                          GameData data)
How many PU's does it cost the given player to produce the given unit type.

If the player cannot produce the given unit, return Integer.MAX_VALUE


getCostComparator

public static java.util.Comparator<Unit> getCostComparator()
Returns:
a comparator that sorts cheaper units before expensive ones

getProductionRule

public static ProductionRule getProductionRule(UnitType unitType,
                                               PlayerID player,
                                               GameData data)
Get the production rule for the given player, for the given unit type.

If no such rule can be found, then return null.


strength

public static float strength(java.util.Collection<Unit> units,
                             boolean attacking,
                             boolean sea)
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: