|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object soc.robot.SOCPossiblePiece
public abstract class SOCPossiblePiece
Pieces that a player might build, or action (buy card) a player might take.
Used by SOCRobotDM
for tracking and planning moves.
Also tracks threats (opponents' possible pieces) to each of our player's possible pieces. Examples of threats are opponent roads on the same edge as this road, settlements or cities that split a road, etc.
Although it's not a board piece type, SOCPossibleCard
is a type here
because the player could buy them as part of a building plan.
Field Summary | |
---|---|
protected java.util.Vector<SOCPossiblePiece> |
biggestThreats
this is the piece that we need to beat to build this one |
static int |
CARD
Type constant for a possible card. |
static int |
CITY
Type constant for a possible city. |
protected int |
coord
Where this piece is on the board. |
protected int |
eta
this is how soon we estimate we can build this piece measured in turns (ETA) |
protected boolean |
hasBeenExpanded
this flag is used for expansion |
static int |
MAXPLUSONE
|
static int |
MIN
MIN is -3 for PICK_SPECIAL , but nothing currently uses -1. |
static int |
PICK_SPECIAL
Type constant for SOCSetSpecialItem.OP_PICK requests, subclass SOCPossiblePickSpecialItem . |
protected int |
pieceType
The type of this playing piece; a constant such as ROAD , CITY , etc. |
protected SOCPlayer |
player
The player who owns this piece |
static int |
ROAD
Type constant for a possible road. |
protected float |
score
this is a score used for deciding what to build next |
static int |
SETTLEMENT
Type constant for a possible settlement. |
static int |
SHIP
Ship, for large sea board. |
protected java.util.Vector<SOCPossiblePiece> |
threats
pieces that threaten this piece |
protected boolean |
threatUpdatedFlag
this flag is used for threat updating |
protected boolean |
updated
this is a flag used for updating |
Constructor Summary | |
---|---|
protected |
SOCPossiblePiece(int pt,
SOCPlayer pl,
int coord)
Construct a SOCPossiblePiece. |
Method Summary | |
---|---|
void |
addBiggestThreat(SOCPossiblePiece bt)
set the biggest threat |
void |
addThreat(SOCPossiblePiece piece)
add a threat to the list, if not already there |
void |
addToScore(float amt)
add to score, from SOCRobotDM.getETABonus(int, int, float) |
void |
clearBiggestThreats()
reset the biggest threat |
void |
clearThreats()
clear the list of threats |
void |
clearUpdateFlag()
clear the update flag |
java.util.Vector<SOCPossiblePiece> |
getBiggestThreats()
|
int |
getCoordinates()
Get this piece's coordinates on the board, if any. |
int |
getETA()
|
SOCPlayer |
getPlayer()
|
SOCResourceSet |
getResourcesToBuild()
Based on piece type ( getType() ), the resources
a player needs to build or buy this possible piece. |
float |
getScore()
|
java.util.Vector<SOCPossiblePiece> |
getThreats()
Get the list of opponents' possible pieces that threaten this possible piece. |
int |
getType()
|
boolean |
hasBeenExpanded()
|
boolean |
isETAUpdated()
|
boolean |
isThreatUpdated()
|
void |
resetExpandedFlag()
set hasBeenExpanded to false |
void |
resetScore()
reset the score |
void |
setETA(int e)
update the ETA for this piece |
void |
setExpandedFlag()
set hasBeenExpanded to true |
void |
subtractFromScore(float amt)
subtract from score |
void |
threatUpdated()
mark this piece as having been threat updated |
java.lang.String |
toString()
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final int ROAD
SOCPlayingPiece.ROAD
.
public static final int SETTLEMENT
SOCPlayingPiece.SETTLEMENT
.
public static final int CITY
SOCPlayingPiece.CITY
.
public static final int SHIP
SOCPlayingPiece.SHIP
.
public static final int CARD
getCoordinates()
field is not used.
CARD is -2, was 4 before v2.0.00.
public static final int PICK_SPECIAL
SOCSetSpecialItem.OP_PICK
requests, subclass SOCPossiblePickSpecialItem
.
getCoordinates()
field is not used.
public static final int MIN
PICK_SPECIAL
, but nothing currently uses -1. ROAD
is 0.
public static final int MAXPLUSONE
protected int pieceType
ROAD
, CITY
, etc.
The constant types are the same as in SOCPlayingPiece.getResourcesToBuild(int)
.
protected SOCPlayer player
protected int coord
CARD
do not use this field, it will be 0 if unused.
In some board layouts 0 is a valid coordinate; check the piece type to determine if unused.
protected int eta
protected boolean updated
protected float score
protected java.util.Vector<SOCPossiblePiece> biggestThreats
protected java.util.Vector<SOCPossiblePiece> threats
protected boolean threatUpdatedFlag
protected boolean hasBeenExpanded
Constructor Detail |
---|
protected SOCPossiblePiece(int pt, SOCPlayer pl, int coord)
pt
- Piece type: ROAD
, CARD
, etc.
The type constants are the same as in SOCPlayingPiece.getResourcesToBuild(int)
.pl
- The owner of this piececoord
- The coordinates for this piece, if any.
Some piece types such as CARD
do not use this field, they call with coord
== 0.Method Detail |
---|
public int getType()
ROAD
, CITY
, etc.
The type constants are the same as in SOCPlayingPiece.getResourcesToBuild(int)
.getResourcesToBuild()
public SOCPlayer getPlayer()
public int getCoordinates()
CARD
do not use this field.
public int getETA()
public void setETA(int e)
e
- the new ETApublic boolean isETAUpdated()
public void clearUpdateFlag()
public void resetScore()
public void addToScore(float amt)
SOCRobotDM.getETABonus(int, int, float)
amt
- the amount to addpublic void subtractFromScore(float amt)
amt
- the amount to subtractpublic float getScore()
SOCRobotDM.getETABonus(int, int, float)
public void clearBiggestThreats()
public void addBiggestThreat(SOCPossiblePiece bt)
bt
- the threatpublic java.util.Vector<SOCPossiblePiece> getBiggestThreats()
public java.util.Vector<SOCPossiblePiece> getThreats()
public void addThreat(SOCPossiblePiece piece)
piece
- Opponent's possible piece to add to this possible piece's threat listpublic boolean isThreatUpdated()
public void clearThreats()
public void threatUpdated()
public boolean hasBeenExpanded()
public void resetExpandedFlag()
public void setExpandedFlag()
public SOCResourceSet getResourcesToBuild()
getType()
), the resources
a player needs to build or buy this possible piece.
Unlike SOCPlayingPiece.getResourcesToBuild(int)
, this method handles
non-piece types which the bot may plan to build, such as PICK_SPECIAL
.
null
if no cost or if piece type unknownpublic java.lang.String toString()
toString
in class java.lang.Object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |