|
JSettlers v1.0.6 API Built ${date} |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.lang.Thread
soc.robot.SOCRobotBrain
AI for playing Settlers of Catan
Field Summary | |
protected boolean |
alive
Flag for wheather or not we're alive |
protected java.util.Stack |
buildingPlan
This is our current building plan |
protected SOCRobotClient |
client
The client we are hooked up to |
protected int |
counter
A counter used to measure passage of time |
protected int |
currentDRecorder
keeps track of which dRecorder is current |
protected int |
curState
Our current state |
protected SOCRobotDM |
decisionMaker
the thing that determines what we want to build next |
protected boolean |
doneTrading
true if we're done trading |
protected DebugRecorder[] |
dRecorder
an object for recording debug information that can be accessed interactively |
protected boolean |
expectDICERESULT
true if we're expecting a DICERESULT message |
protected boolean |
expectDISCARD
true if we're expecting a DISCARDREQUEST message |
protected boolean |
expectMOVEROBBER
true if we're expecting to have to move the robber |
protected boolean |
expectPLACING_CITY
true if we're expecting the PLACING_CITY state |
protected boolean |
expectPLACING_FREE_ROAD1
true if we're expecting the PLACING_FREE_ROAD1 state |
protected boolean |
expectPLACING_FREE_ROAD2
true if we're expecting the PLACING_FREE_ROAD2 state |
protected boolean |
expectPLACING_ROAD
true if we're expecting the PLACING_ROAD state |
protected boolean |
expectPLACING_ROBBER
true if we're expecting the PLACING_ROBBER state |
protected boolean |
expectPLACING_SETTLEMENT
true if we're expecting the PLACING_SETTLEMENT state |
protected boolean |
expectPLAY
true if we're expecting the PLAY state |
protected boolean |
expectPLAY1
true if we're expecting the PLAY1 state |
protected boolean |
expectPUTPIECE_FROM_START1A
true if were expecting a PUTPIECE message after a START1A game state |
protected boolean |
expectPUTPIECE_FROM_START1B
true if were expecting a PUTPIECE message after a START1B game state |
protected boolean |
expectPUTPIECE_FROM_START2A
true if were expecting a PUTPIECE message after a START1A game state |
protected boolean |
expectPUTPIECE_FROM_START2B
true if were expecting a PUTPIECE message after a START1A game state |
protected boolean |
expectSTART1A
true if we're expecting the START1A state |
protected boolean |
expectSTART1B
true if we're expecting the START1B state |
protected boolean |
expectSTART2A
true if we're expecting the START2A state |
protected boolean |
expectSTART2B
true if we're expecting the START2B state |
protected boolean |
expectWAITING_FOR_DISCOVERY
true if we're expecting to pick two resources |
protected boolean |
expectWAITING_FOR_MONOPOLY
true if we're expecting to pick a monopoly |
protected int |
firstSettlement
used in planning where to put our first and second settlements |
protected SOCGame |
game
The game we are playing |
protected CappedQueue |
gameEventQ
The queue of game messages |
protected SOCPossiblePiece |
lastMove
keeps track of the last thing we bought for debugging purposes |
protected SOCPossiblePiece |
lastTarget
keeps track of the last thing we wanted for debugging purposes |
protected int |
monopolyChoice
this is the resource we want to monopolize |
protected boolean |
moveRobberOnSeven
true when the robber will move because a seven was rolled |
protected SOCRobotNegotiator |
negotiator
the thing that determines how we negotiate |
protected boolean[] |
offerRejections
true if the player with that player number has rejected our offer |
protected int |
oldGameState
the game state before the current one |
protected SOCPlayer |
ourPlayerData
Our player data |
protected SOCPlayerTracker |
ourPlayerTracker
our player tracker |
protected boolean |
ourTurn
Flag for wheather or not it is our turn |
protected SOCRobotPinger |
pinger
a thread that sends ping messages to this one |
protected java.util.HashMap |
playerTrackers
trackers for all players |
protected java.util.Random |
rand
Random number generator |
protected SOCResourceSet |
resourceChoices
these are the two resources that we want when we play a discovery dev card |
protected int[] |
resourceEstimates
used to cache resource estiamtes for the board |
protected int |
secondSettlement
used in planning where to put our first and second settlements |
protected int |
turnTime
Timer for turn taking |
protected boolean |
waitingForDevCard
true when we're waiting to receive a dev card |
protected boolean |
waitingForGameState
true if we're waiting for a GAMESTATE message from the server |
protected boolean |
waitingForOurTurn
true if we're waiting for a TURN message from the server when it's our turn |
protected boolean |
waitingForTradeMsg
true when we're waiting for the results of a trade |
protected boolean |
waitingForTradeResponse
|
protected SOCPlayingPiece |
whatWeWantToBuild
This is what we want to build |
Fields inherited from class java.lang.Thread |
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY |
Constructor Summary | |
SOCRobotBrain(SOCRobotClient rc,
SOCRobotParameters params,
SOCGame ga,
CappedQueue mq)
Create a robot brain to play a game |
Method Summary | |
protected void |
bestSpot2AwayFromANodeSet(java.util.Hashtable nodesIn,
java.util.Vector nodeSet,
int weight)
Takes a table of nodes and adds a weighted score to each node score in the table. |
protected void |
bestSpotForNumbers(java.util.Hashtable nodes,
int weight)
Takes a table of nodes and adds a weighted score to each node score in the table. |
protected void |
bestSpotForNumbers(java.util.Hashtable nodes,
SOCPlayer player,
int weight)
Takes a table of nodes and adds a weighted score to each node score in the table. |
protected void |
bestSpotInANodeSet(java.util.Hashtable nodesIn,
java.util.Vector nodeSet,
int weight)
Takes a table of nodes and adds a weighted score to each node score in the table. |
protected void |
chooseFreeResources(SOCResourceSet targetResources)
this means that we want to play a discovery development card |
protected boolean |
chooseMonopoly()
choose a resource to monopolize |
protected void |
chooseRobberVictim(boolean[] choices)
choose a robber victim |
protected int |
considerOffer(SOCTradeOffer offer)
consider an offer made by another player |
protected void |
discard(int numDiscards)
discard some resources |
protected int[] |
estimateResourceRarity()
estimate the rarity of each resource |
protected void |
expandTradeTreeNode(SOCTradeTree currentTreeNode,
java.util.Hashtable table)
expand a trade tree node |
protected soc.robot.BoardNodeScorePair |
findBestScoringNode(java.util.Hashtable nodes)
given a table of nodes/edges with scores, return the best scoring pair |
java.util.Stack |
getBuildingPlan()
|
SOCRobotClient |
getClient()
|
SOCRobotDM |
getDecisionMaker()
|
DebugRecorder |
getDRecorder()
|
SOCGame |
getGame()
|
SOCPossiblePiece |
getLastMove()
|
SOCPossiblePiece |
getLastTarget()
|
DebugRecorder |
getOldDRecorder()
|
SOCPlayer |
getOurPlayerData()
|
SOCPlayerTracker |
getOurPlayerTracker()
|
java.util.HashMap |
getPlayerTrackers()
|
SOCRobotParameters |
getRobotParameters()
|
void |
kill()
kill this brain |
protected boolean |
makeCounterOffer(SOCTradeOffer offer)
make a counter offer to another player |
protected boolean |
makeOffer(SOCPossiblePiece target)
make an offer to another player |
protected void |
moveRobber()
/** move the robber |
protected int |
numberOfEnemyBuilds()
calculate the number of builds before the next turn during init placement |
void |
pause(int msec)
pause for a bit |
protected void |
placeFirstSettlement()
place planned first settlement |
void |
placeInitRoad()
place a road attached to the last initial settlement |
protected void |
placeSecondSettlement()
place planned second settlement |
protected void |
planInitialSettlements()
figure out where to place the two settlements |
protected void |
planSecondSettlement()
figure out where to place the second settlement |
void |
run()
Here is the run method. |
protected void |
scoreNodesForSettlements(java.util.Hashtable nodes,
int numberWeight,
int miscPortWeight,
int portWeight)
this is a function more for convience given a set of nodes, run a bunch of metrics across them to find which one is best for building a settlement |
protected int |
scoreTradeOutcome(SOCResourceSet tradeOutcome)
evaluate a trade outcome by calculating how much you could build with it |
void |
setOurPlayerData()
Find our player data using our nickname |
protected void |
tradeStuff()
do some trading |
protected boolean |
tradeToTarget2(SOCResourceSet targetResources)
make trades to get the target resources |
void |
turnOffDRecorder()
turns the debug recorders off |
void |
turnOnDRecorder()
turns the debug recorders on |
Methods inherited from class java.lang.Thread |
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getContextClassLoader, getName, getPriority, getThreadGroup, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setName, setPriority, sleep, sleep, start, stop, stop, suspend, toString, yield |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
protected boolean alive
protected boolean ourTurn
protected int turnTime
protected int curState
protected java.util.Random rand
protected SOCRobotClient client
protected SOCGame game
protected SOCPlayer ourPlayerData
protected CappedQueue gameEventQ
protected int counter
protected SOCPlayingPiece whatWeWantToBuild
protected java.util.Stack buildingPlan
protected SOCResourceSet resourceChoices
protected int monopolyChoice
protected SOCPlayerTracker ourPlayerTracker
protected java.util.HashMap playerTrackers
protected SOCRobotDM decisionMaker
protected SOCRobotNegotiator negotiator
protected boolean expectSTART1A
protected boolean expectSTART1B
protected boolean expectSTART2A
protected boolean expectSTART2B
protected boolean expectPLAY
protected boolean expectPLAY1
protected boolean expectPLACING_ROAD
protected boolean expectPLACING_SETTLEMENT
protected boolean expectPLACING_CITY
protected boolean expectPLACING_ROBBER
protected boolean expectPLACING_FREE_ROAD1
protected boolean expectPLACING_FREE_ROAD2
protected boolean expectPUTPIECE_FROM_START1A
protected boolean expectPUTPIECE_FROM_START1B
protected boolean expectPUTPIECE_FROM_START2A
protected boolean expectPUTPIECE_FROM_START2B
protected boolean expectDICERESULT
protected boolean expectDISCARD
protected boolean expectMOVEROBBER
protected boolean expectWAITING_FOR_DISCOVERY
protected boolean expectWAITING_FOR_MONOPOLY
protected boolean waitingForGameState
protected boolean waitingForOurTurn
protected boolean waitingForTradeMsg
protected boolean waitingForDevCard
protected boolean moveRobberOnSeven
protected boolean waitingForTradeResponse
protected boolean doneTrading
protected boolean[] offerRejections
protected int oldGameState
protected int[] resourceEstimates
protected int firstSettlement
protected int secondSettlement
protected SOCRobotPinger pinger
protected DebugRecorder[] dRecorder
protected int currentDRecorder
protected SOCPossiblePiece lastMove
protected SOCPossiblePiece lastTarget
Constructor Detail |
public SOCRobotBrain(SOCRobotClient rc, SOCRobotParameters params, SOCGame ga, CappedQueue mq)
rc
- the robot clientparams
- the robot parametersga
- the game we're playingmq
- the message queueMethod Detail |
public SOCRobotParameters getRobotParameters()
public SOCRobotClient getClient()
public java.util.HashMap getPlayerTrackers()
public SOCPlayerTracker getOurPlayerTracker()
public SOCGame getGame()
public SOCPlayer getOurPlayerData()
public java.util.Stack getBuildingPlan()
public SOCRobotDM getDecisionMaker()
public void turnOnDRecorder()
public void turnOffDRecorder()
public DebugRecorder getDRecorder()
public DebugRecorder getOldDRecorder()
public SOCPossiblePiece getLastMove()
public SOCPossiblePiece getLastTarget()
public void setOurPlayerData()
public void run()
public void kill()
public void pause(int msec)
msec
- number of milliseconds to pauseprotected void planInitialSettlements()
protected void planSecondSettlement()
protected void placeFirstSettlement()
protected void placeSecondSettlement()
public void placeInitRoad()
protected int[] estimateResourceRarity()
protected void bestSpotForNumbers(java.util.Hashtable nodes, int weight)
nodes
- the table of nodes with scoresweight
- a number that is multiplied by the scoreprotected void bestSpotForNumbers(java.util.Hashtable nodes, SOCPlayer player, int weight)
nodes
- the table of nodes with scoresplayer
- the player that we are doing the rating forweight
- a number that is multiplied by the scoreprotected void bestSpot2AwayFromANodeSet(java.util.Hashtable nodesIn, java.util.Vector nodeSet, int weight)
nodesIn
- the table of nodes to evaluatenodeSet
- the set of desired nodesweight
- the score multiplierprotected void bestSpotInANodeSet(java.util.Hashtable nodesIn, java.util.Vector nodeSet, int weight)
nodesIn
- the table of nodes to evaluatenodeSet
- the set of desired nodesweight
- the score multiplierprotected void moveRobber()
protected void discard(int numDiscards)
numDiscards
- the number of resources to discardprotected void chooseRobberVictim(boolean[] choices)
choices
- a boolean array representing which players are possible victimsprotected int numberOfEnemyBuilds()
protected soc.robot.BoardNodeScorePair findBestScoringNode(java.util.Hashtable nodes)
nodes
- the table of nodes/edges
protected void scoreNodesForSettlements(java.util.Hashtable nodes, int numberWeight, int miscPortWeight, int portWeight)
nodes
- a hashtable of nodes, the scores in the table will be modifiednumberWeight
- the weight given to nodes on good numbersmiscPortWeight
- the weight given to nodes on 3:1 portsportWeight
- the weight given to nodes on good 2:1 portsprotected void tradeStuff()
protected void expandTradeTreeNode(SOCTradeTree currentTreeNode, java.util.Hashtable table)
currentTreeNode
- the tree node that we're expandingtable
- the table of all of the nodes in the tree except this oneprotected int scoreTradeOutcome(SOCResourceSet tradeOutcome)
tradeOutcome
- a set of resources that would be the result of tradingprotected boolean tradeToTarget2(SOCResourceSet targetResources)
targetResources
- the resources that we want
protected int considerOffer(SOCTradeOffer offer)
offer
- the offer to consider
protected boolean makeOffer(SOCPossiblePiece target)
target
- the resources that we want
protected boolean makeCounterOffer(SOCTradeOffer offer)
offer
- their offer
protected void chooseFreeResources(SOCResourceSet targetResources)
protected boolean chooseMonopoly()
|
JSettlers v1.0.6 API Built ${date} |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |