JSettlers v1.0.6 API
Built ${date}

soc.robot
Class SOCPlayerTracker

java.lang.Object
  extended bysoc.robot.SOCPlayerTracker

public class SOCPlayerTracker
extends java.lang.Object

This class is used by the SOCRobotBrain to track possible building spots for itself and other players.

Author:
Robert S Thomas

Field Summary
protected  SOCRobotBrain brain
           
protected static java.text.DecimalFormat df1
           
protected static int EXPAND_LEVEL
           
protected  int knightsToBuy
           
protected  int largestArmyETA
           
protected  int longestRoadETA
           
protected static int LR_CALC_LEVEL
           
protected  boolean needLA
           
protected  boolean needLR
           
protected  SOCPlayer player
           
protected  java.util.TreeMap possibleCities
           
protected  java.util.TreeMap possibleRoads
           
protected  java.util.TreeMap possibleSettlements
           
protected  int roadsToGo
           
protected  int winGameETA
           
 
Constructor Summary
SOCPlayerTracker(SOCPlayer pl, SOCRobotBrain br)
          constructor
SOCPlayerTracker(SOCPlayerTracker pt)
          copy constructor Note: Does NOT copy connections between possible pieces
 
Method Summary
 void addNewRoad(SOCRoad road, java.util.HashMap trackers)
          add a road that has just been built
 void addNewSettlement(SOCSettlement settlement, java.util.HashMap trackers)
          add a settlement that has just been built
 void addOurNewCity(SOCCity city)
          add one of our cities
 void addOurNewRoad(SOCRoad road, java.util.HashMap trackers, int expandLevel)
          Add one of our roads that has just been built
 void addOurNewSettlement(SOCSettlement settlement, java.util.HashMap trackers)
          add one of our settlements
 void addTheirNewRoad(SOCRoad road)
          add another player's new road
 void addTheirNewSettlement(SOCSettlement settlement)
          add another player's new settlement
static java.util.HashMap copyPlayerTrackers(java.util.HashMap trackers)
          make copies of player trackers and then make connections between copied pieces Note: not copying threats param trackers player trackers for each player
 void expandRoad(SOCPossibleRoad targetRoad, SOCPlayer player, SOCPlayer dummy, java.util.HashMap trackers, int level)
          Expand a possible road to see what this road makes possible
 SOCRobotBrain getBrain()
           
 int getKnightsToBuy()
           
 int getLargestArmyETA()
           
 int getLongestRoadETA()
           
 SOCPlayer getPlayer()
           
 java.util.TreeMap getPossibleCities()
           
 java.util.TreeMap getPossibleRoads()
           
 java.util.TreeMap getPossibleSettlements()
           
 int getRoadsToGo()
           
 int getWinGameETA()
           
 boolean needsLA()
           
 boolean needsLR()
           
static void playerTrackersDebug(java.util.HashMap playerTrackers)
          debug output for player trackers
 void recalcLargestArmyETA()
          calculate the largest army ETA
 void recalcLongestRoadETA()
          calculate the longest road ETA
 void recalcWinGameETA()
          recalculate the ETA for winning the game
 void releaseMonitor()
          release the monitor for this tracker
protected  void removeDependents(SOCPossibleRoad road)
          remove everything that depends on this road being built
protected  void removeFromNecessaryRoads(SOCPossibleRoad pr)
          remove this piece from the pieces that support it
protected  void removeFromNecessaryRoads(SOCPossibleSettlement ps)
          remove this piece from the pieces that support it
 void takeMonitor()
          take the monitor for this tracker
static java.util.HashMap tryPutPiece(SOCPlayingPiece piece, SOCGame game, java.util.HashMap trackers)
          See how building a piece impacts the game
static void tryPutPieceNoCopy(SOCPlayingPiece piece, SOCGame game, java.util.HashMap trackers)
          same as tryPutPiece, but we don't make a copy of the player trackers instead you supply the copy
 void undoAddOurNewCity(SOCPossibleCity city)
          undo adding one of our cities
static void undoTryPutPiece(SOCPlayingPiece piece, SOCGame game)
          Reset the game back to before we put the temp piece
 void updateLRPotential(SOCPossibleRoad posRoad, SOCPlayer dummy, SOCRoad dummyRoad, int lrLength, int level)
          update the potential LR value of a possible road by placing dummy roads and calculating LR
 void updateLRValues()
          update the longest road values for all possible roads longest road value is how much this road would increase our longest road if it were built the longest road potential is how much this road would increase our LR value if other roads supported by this one were built
protected  void updateSettlementConflicts(SOCPossibleSettlement ps, java.util.HashMap trackers)
          update settlement conflicts
 void updateThreats(java.util.HashMap trackers)
          update threats for pieces that need to be updated
static void updateWinGameETAs(java.util.HashMap playerTrackers)
          update winGameETAs for player trackers
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

df1

protected static final java.text.DecimalFormat df1

EXPAND_LEVEL

protected static int EXPAND_LEVEL

LR_CALC_LEVEL

protected static int LR_CALC_LEVEL

brain

protected SOCRobotBrain brain

player

protected SOCPlayer player

possibleSettlements

protected java.util.TreeMap possibleSettlements

possibleRoads

protected java.util.TreeMap possibleRoads

possibleCities

protected java.util.TreeMap possibleCities

longestRoadETA

protected int longestRoadETA

roadsToGo

protected int roadsToGo

largestArmyETA

protected int largestArmyETA

winGameETA

protected int winGameETA

knightsToBuy

protected int knightsToBuy

needLR

protected boolean needLR

needLA

protected boolean needLA
Constructor Detail

SOCPlayerTracker

public SOCPlayerTracker(SOCPlayer pl,
                        SOCRobotBrain br)
constructor

Parameters:
pl - the player
br - the robot brain

SOCPlayerTracker

public SOCPlayerTracker(SOCPlayerTracker pt)
copy constructor Note: Does NOT copy connections between possible pieces

Parameters:
pt - the player tracker
Method Detail

copyPlayerTrackers

public static java.util.HashMap copyPlayerTrackers(java.util.HashMap trackers)
make copies of player trackers and then make connections between copied pieces Note: not copying threats param trackers player trackers for each player


takeMonitor

public void takeMonitor()
take the monitor for this tracker


releaseMonitor

public void releaseMonitor()
release the monitor for this tracker


getBrain

public SOCRobotBrain getBrain()
Returns:
the robot brain for this tracker

getPlayer

public SOCPlayer getPlayer()
Returns:
the player for this tracker

getPossibleRoads

public java.util.TreeMap getPossibleRoads()
Returns:
the list of possible roads

getPossibleSettlements

public java.util.TreeMap getPossibleSettlements()
Returns:
the list of possible settlements

getPossibleCities

public java.util.TreeMap getPossibleCities()
Returns:
the list of possible cities

getLongestRoadETA

public int getLongestRoadETA()
Returns:
the longest road eta

getRoadsToGo

public int getRoadsToGo()
Returns:
how many roads needed to build to take longest road

getLargestArmyETA

public int getLargestArmyETA()
Returns:
largest army eta

getKnightsToBuy

public int getKnightsToBuy()
Returns:
the number of knights to buy to get LA

addNewRoad

public void addNewRoad(SOCRoad road,
                       java.util.HashMap trackers)
add a road that has just been built

Parameters:
road - the road
trackers - player trackers for the players

addOurNewRoad

public void addOurNewRoad(SOCRoad road,
                          java.util.HashMap trackers,
                          int expandLevel)
Add one of our roads that has just been built

Parameters:
road - the road
trackers - player trackers for the players
expandLevel - how far out we should expand roads

expandRoad

public void expandRoad(SOCPossibleRoad targetRoad,
                       SOCPlayer player,
                       SOCPlayer dummy,
                       java.util.HashMap trackers,
                       int level)
Expand a possible road to see what this road makes possible

Parameters:
targetRoad - the possible road
player - the player who owns the original road
dummy - the dummy player used to see what's legal
trackers - player trackers
level - how many levels to expand

addTheirNewRoad

public void addTheirNewRoad(SOCRoad road)
add another player's new road

Parameters:
road - the new road

updateSettlementConflicts

protected void updateSettlementConflicts(SOCPossibleSettlement ps,
                                         java.util.HashMap trackers)
update settlement conflicts

Parameters:
ps - a possible settlement
trackers - player trackers for all players

addNewSettlement

public void addNewSettlement(SOCSettlement settlement,
                             java.util.HashMap trackers)
add a settlement that has just been built

Parameters:
settlement - the settlement
trackers - player trackers for the players

addOurNewSettlement

public void addOurNewSettlement(SOCSettlement settlement,
                                java.util.HashMap trackers)
add one of our settlements

Parameters:
settlement - the new settlement
trackers - player trackers for all of the players

addTheirNewSettlement

public void addTheirNewSettlement(SOCSettlement settlement)
add another player's new settlement

Parameters:
settlement - the new settlement

removeDependents

protected void removeDependents(SOCPossibleRoad road)
remove everything that depends on this road being built

Parameters:
road - the road

removeFromNecessaryRoads

protected void removeFromNecessaryRoads(SOCPossibleRoad pr)
remove this piece from the pieces that support it

Parameters:
pr - the possible road

removeFromNecessaryRoads

protected void removeFromNecessaryRoads(SOCPossibleSettlement ps)
remove this piece from the pieces that support it

Parameters:
ps - the possible settlement

addOurNewCity

public void addOurNewCity(SOCCity city)
add one of our cities

Parameters:
city - the new city

undoAddOurNewCity

public void undoAddOurNewCity(SOCPossibleCity city)
undo adding one of our cities

Parameters:
city - the now possible city

updateThreats

public void updateThreats(java.util.HashMap trackers)
update threats for pieces that need to be updated

Parameters:
trackers - all of the player trackers

recalcLongestRoadETA

public void recalcLongestRoadETA()
calculate the longest road ETA


recalcLargestArmyETA

public void recalcLargestArmyETA()
calculate the largest army ETA


updateLRValues

public void updateLRValues()
update the longest road values for all possible roads longest road value is how much this road would increase our longest road if it were built the longest road potential is how much this road would increase our LR value if other roads supported by this one were built


updateLRPotential

public void updateLRPotential(SOCPossibleRoad posRoad,
                              SOCPlayer dummy,
                              SOCRoad dummyRoad,
                              int lrLength,
                              int level)
update the potential LR value of a possible road by placing dummy roads and calculating LR

Parameters:
posRoad - the possible road
dummy - the dummy player
lrLength - the current lr length
level - how many levels of recursion

getWinGameETA

public int getWinGameETA()
Returns:
the ETA for winning the game

needsLR

public boolean needsLR()
Returns:
true if this player needs LR to win

needsLA

public boolean needsLA()
Returns:
true if this player needs LA to win

recalcWinGameETA

public void recalcWinGameETA()
recalculate the ETA for winning the game


tryPutPiece

public static java.util.HashMap tryPutPiece(SOCPlayingPiece piece,
                                            SOCGame game,
                                            java.util.HashMap trackers)
See how building a piece impacts the game

Parameters:
piece - the piece to build
game - the game
trackers - the player trackers
Returns:
a copy of the player trackers with the new piece in place

tryPutPieceNoCopy

public static void tryPutPieceNoCopy(SOCPlayingPiece piece,
                                     SOCGame game,
                                     java.util.HashMap trackers)
same as tryPutPiece, but we don't make a copy of the player trackers instead you supply the copy

Parameters:
piece - the piece to build
game - the game
trackers - the player trackers

undoTryPutPiece

public static void undoTryPutPiece(SOCPlayingPiece piece,
                                   SOCGame game)
Reset the game back to before we put the temp piece

Parameters:
piece - the piece to remove
game - the game

playerTrackersDebug

public static void playerTrackersDebug(java.util.HashMap playerTrackers)
debug output for player trackers

Parameters:
playerTrackers - the player trackers

updateWinGameETAs

public static void updateWinGameETAs(java.util.HashMap playerTrackers)
update winGameETAs for player trackers

Parameters:
playerTrackers - the player trackers

JSettlers v1.0.6 API
Built ${date}