|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectsoc.robot.OpeningBuildStrategy
public class OpeningBuildStrategy
This class is a temporary class put in place to slowly pull tasks out of SOCRobotBrain and start replacing them with classes that implement strategy interfaces. (Strategy Pattern)
| Field Summary | |
|---|---|
protected int |
firstSettlement
used in planning where to put our first and second settlements |
private SOCGame |
game
Our game |
private D |
log
debug logging |
private SOCPlayer |
ourPlayerData
Our SOCRobotBrain's player |
private int |
plannedRoadDestinationNode
Coordinate of a future settlement 2 nodes away from settlementNode (from firstSettlement or secondSettlement). |
protected int[] |
resourceEstimates
Cached resource estimates for the board; resourceEstimates[ SOCBoard.CLAY_HEX] == the clay rarity,
as an integer percentage 0-100 of dice rolls. |
protected int |
secondSettlement
used in planning where to put our first and second settlements |
| Constructor Summary | |
|---|---|
OpeningBuildStrategy(SOCGame ga,
SOCPlayer pl)
Create an OpeningBuildStrategy for a SOCRobotBrain's player. |
|
| Method Summary | |
|---|---|
protected void |
bestSpot2AwayFromANodeSet(SOCBoard board,
java.util.Hashtable<java.lang.Integer,java.lang.Integer> nodesIn,
java.util.Vector<java.lang.Integer> 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<java.lang.Integer,java.lang.Integer> 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<java.lang.Integer,java.lang.Integer> nodesIn,
java.util.Vector<java.lang.Integer> nodeSet,
int weight)
Takes a table of nodes and adds a weighted score to each node score in the table. |
int[] |
estimateResourceRarity()
Estimate the rarity of each resource, given this board's resource locations vs dice numbers. |
int |
getPlannedInitRoadDestinationNode()
Get the node coordinate of a future settlement 2 nodes away from our most recent settlement node. |
protected int |
numberOfEnemyBuilds()
Calculate the number of builds before our next turn during init placement. |
int |
planInitialSettlements()
figure out where to place the two settlements |
int |
planInitRoad()
Plan and place a road attached to our most recently placed initial settlement, in game states START1B, START2B, START3B. |
int |
planSecondSettlement()
figure out where to place the second settlement |
protected void |
scoreNodesForSettlements(java.util.Hashtable<java.lang.Integer,java.lang.Integer> nodes,
int numberWeight,
int miscPortWeight,
int portWeight)
Given a set of nodes, run a bunch of metrics across them to find which one is best for building a settlement. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
private final SOCGame game
private final SOCPlayer ourPlayerData
SOCRobotBrain's player
private transient D log
protected int firstSettlement
protected int secondSettlement
private int plannedRoadDestinationNode
firstSettlement or secondSettlement).
Valid after calling planInitRoad().
protected int[] resourceEstimates
SOCBoard.CLAY_HEX] == the clay rarity,
as an integer percentage 0-100 of dice rolls.
Initialized in estimateResourceRarity().
| Constructor Detail |
|---|
OpeningBuildStrategy(SOCGame ga,
SOCPlayer pl)
SOCRobotBrain's player.
ga - Our gamepl - Our player data in ga| Method Detail |
|---|
public int getPlannedInitRoadDestinationNode()
planInitRoad().
public int planInitialSettlements()
firstSettlement, or 0 if no potential settlements for our playerpublic int planSecondSettlement()
secondSettlement, or -1 if nonepublic int planInitRoad()
START1B, START2B, START3B.
Also sets getPlannedInitRoadDestinationNode().
Road choice is based on the best nearby potential settlements, and doesn't
directly check ourPlayerData.isPotentialRoad(edgeCoord).
If the server rejects our road choice, then SOCRobotBrain.cancelWrongPiecePlacementLocal(SOCPlayingPiece)
will need to know which settlement node we were aiming for,
and call ourPlayerData.clearPotentialSettlement(nodeCoord).
The SOCRobotBrain.lastStartingRoadTowardsNode field holds this coordinate.
protected void scoreNodesForSettlements(java.util.Hashtable<java.lang.Integer,java.lang.Integer> nodes,
int numberWeight,
int miscPortWeight,
int portWeight)
nodes - a hashtable of nodes; the scores in the table will be modified.
Key = coord Integer; value = score Integer.numberWeight - 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 ports
protected void bestSpotInANodeSet(java.util.Hashtable<java.lang.Integer,java.lang.Integer> nodesIn,
java.util.Vector<java.lang.Integer> nodeSet,
int weight)
nodesIn - the table of nodes to evaluate: Hashtable<Integer,Integer> .
Contents will be modified by the scoring.nodeSet - the set of desired nodesweight - the score multiplier
protected void bestSpot2AwayFromANodeSet(SOCBoard board,
java.util.Hashtable<java.lang.Integer,java.lang.Integer> nodesIn,
java.util.Vector<java.lang.Integer> nodeSet,
int weight)
board - the game boardnodesIn - the table of nodes to evaluate: Hashtable<Integer,Integer> .
Contents will be modified by the scoring.nodeSet - the set of desired nodesweight - the score multiplierpublic int[] estimateResourceRarity()
resourceEstimates.
Calls each hex's SOCBoard.getHexTypeFromCoord(int), ignores all hex types besides
the usual SOCBoard.CLAY_HEX through SOCBoard.WOOD_HEX and SOCBoardLarge.GOLD_HEX.
protected int numberOfEnemyBuilds()
protected void bestSpotForNumbers(java.util.Hashtable<java.lang.Integer,java.lang.Integer> nodes,
SOCPlayer player,
int weight)
nodes - the table of nodes with scores: Hashtable<Integer,Integer> .
Contents will be modified by the scoring.player - the player that we are doing the rating for, or null;
will give a bonus to numbers the player isn't already touchingweight - a number that is multiplied by the score
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||