Class RationalAI

All Implemented Interfaces:
AI
Direct Known Subclasses:
HumanHaterRationalAI, MilvangAI

public class RationalAI extends SimpleAI
Simple implementation of a Titan AI
Author:
Bruce Sherrod, David Ripton, Romain Dolbeau, Corwin Joy, extensively rewritten on 02-Oct-2003
  • Field Details

  • Constructor Details

    • RationalAI

      public RationalAI(Client client)
  • Method Details

    • r3

      private static double r3(double value)
    • split

      public boolean split()
      Description copied from interface: AI
      make splits for current player. Return true if done
      Specified by:
      split in interface AI
      Overrides:
      split in class SimpleAI
    • fireSplits

      private boolean fireSplits()
      Return true if done with all splits and callbacks
    • splitCallback

      public boolean splitCallback(Legion parent, Legion child)
      If parentId and childId are null, this is a callback to an undo split
      Specified by:
      splitCallback in interface AI
      Overrides:
      splitCallback in class SimpleAI
    • expectedValueSplitLegion

      private double expectedValueSplitLegion(LegionClientSide legion, LegionClientSide child_legion)
    • splitOneLegion

      boolean splitOneLegion(Player player, Legion legion)
      Return true if done, false if waiting for callback.
    • splitOneLegionCallback

      private boolean splitOneLegionCallback(LegionClientSide parent, LegionClientSide child)
      Return true if done, false if waiting for undo split
    • recruitValue

      private double recruitValue(Legion legion, MasterHex hex, Legion enemy, MasterBoardTerrain terrain)
      Find value of recruiting, including possibly attacking an enemy set enemy = null to indicate no enemy
    • removeMustered

      private List<CreatureType> removeMustered(List<CreatureType> sortedCreatures)
    • sortCreaturesByValueName

      private List<CreatureType> sortCreaturesByValueName(Legion legion)
    • chooseCreaturesToSplitOut

      RationalAI.MusteredCreatures chooseCreaturesToSplitOut(Legion legion, boolean at_risk)
      Decide how to split this legion, and return a list of Creatures to remove + status flag indicating if these creatures have mustered or not
    • masterMove

      public boolean masterMove()
      Return true if we need to run this method again after the server updates the client with the results of a move or mulligan.
      Specified by:
      masterMove in interface AI
      Overrides:
      masterMove in class SimpleAI
    • findMoveList

      private boolean findMoveList(List<? extends Legion> legions, List<List<RationalAI.LegionBoardMove>> all_legionMoves, MultiSet<MasterHex> occupiedHexes, boolean teleportsOnly)
    • handleVoluntaryMoves

      private boolean handleVoluntaryMoves(Player player)
      Return true if we moved something and need to be called again.
    • handleForcedSplitMoves

      private boolean handleForcedSplitMoves(Player player)
    • handleForcedSingleMove

      private boolean handleForcedSingleMove(Player player)
    • hexRisk

      private double hexRisk(Legion legion, MasterHex hex, boolean invert)
    • evaluateCombat

      private int evaluateCombat(Legion attacker, Legion defender, MasterHex hex)
    • evaluateHexAttack

      private int evaluateHexAttack(Legion attacker, MasterHex hex, int canRecruitHere)
    • evaluateMove

      private int evaluateMove(Legion legion, MasterHex hex, int canRecruitHere, int depth, boolean addHexRisk)
      Memoizing wrapper for evaluateMoveInner
    • evaluateMoveInner

      private int evaluateMoveInner(Legion legion, MasterHex hex, int canRecruitHere, int depth, boolean normalHexRisk)
    • estimateBattleResults

      RationalAI.BattleResults estimateBattleResults(Legion attacker, Legion defender, MasterHex hex)
    • estimateBattleResults

      private RationalAI.BattleResults estimateBattleResults(Legion attacker, Legion defender, MasterHex hex, CreatureType callable)
    • flee

      public boolean flee(Legion legion, Legion enemy)
      Description copied from interface: AI
      choose whether legion should flee from enemy
      Specified by:
      flee in interface AI
      Overrides:
      flee in class SimpleAI
    • concede

      public boolean concede(Legion legion, Legion enemy)
      Description copied from interface: AI
      choose whether legion should concede to enemy
      Specified by:
      concede in interface AI
      Overrides:
      concede in class SimpleAI
    • getCombatList

      public List<SimpleAI.PowerSkill> getCombatList(Legion legion, MasterBoardTerrain terrain, boolean defender)