|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object soc.robot.SOCBuildingSpeedEstimate
public class SOCBuildingSpeedEstimate
This class calculates approximately how
long it would take a player to build something.
Uses SOCPlayerNumbers
to get resources of currently reached hexes.
Field Summary | |
---|---|
static int |
CARD
|
static int |
CITY
|
static int |
DEFAULT_ROLL_LIMIT
|
(package private) int[] |
estimatesFromNothing
|
(package private) int[] |
estimatesFromNow
|
static int |
MAXPLUSONE
|
static int |
MIN
|
protected static boolean |
recalc
|
private SOCResourceSet[] |
resourcesForRoll
Resource sets gained for each dice roll number (2 to 12). |
static int |
ROAD
|
private int[] |
rollsPerResource
Number of rolls to gain each resource type ( SOCResourceConstants.CLAY
to SOCResourceConstants.WOOD ). |
static int |
SETTLEMENT
|
static int |
SHIP
|
Constructor Summary | |
---|---|
SOCBuildingSpeedEstimate()
Create a new SOCBuildingSpeedEstimate, not yet calculating estimates. |
|
SOCBuildingSpeedEstimate(SOCPlayerNumbers numbers)
Create a new SOCBuildingSpeedEstimate, calculating the rollsPerResource and resourcesPerRoll based on the player's dice numbers (settlement/city hexes). |
Method Summary | |
---|---|
protected SOCResSetBuildTimePair |
calculateRollsAccurate(SOCResourceSet startingResources,
SOCResourceSet targetResources,
int cutoff,
boolean[] ports)
this figures out how many rolls it would take this player to get the target set of resources given a starting set |
protected SOCResSetBuildTimePair |
calculateRollsAndRsrcFast(SOCResourceSet startingResources,
SOCResourceSet targetResources,
int cutoff,
boolean[] ports)
this figures out how many rolls it would take this player to get the target set of resources given a starting set |
protected int |
calculateRollsFast(SOCResourceSet startingResources,
SOCResourceSet targetResources,
int cutoff,
boolean[] ports)
Figures out how many rolls it would take this player to get the target set of resources, given a starting set. |
int[] |
getEstimatesFromNothingAccurate(boolean[] ports)
|
int[] |
getEstimatesFromNothingFast(boolean[] ports)
|
int[] |
getEstimatesFromNothingFast(boolean[] ports,
int limit)
|
int[] |
getEstimatesFromNowAccurate(SOCResourceSet resources,
boolean[] ports)
|
int[] |
getEstimatesFromNowFast(SOCResourceSet resources,
boolean[] ports)
|
static int[] |
getRollsForResourcesSorted(SOCPlayer pl)
Estimate the rolls for this player to obtain each resource. |
int[] |
getRollsPerResource()
Get the number of rolls to gain each resource type ( SOCResourceConstants.CLAY
to SOCResourceConstants.WOOD ). |
void |
recalculateEstimates(SOCPlayerNumbers numbers)
recalculate both rollsPerResource and resourcesPerRoll |
void |
recalculateEstimates(SOCPlayerNumbers numbers,
int robberHex)
Recalculate both rollsPerResource and resourcesPerRoll, optionally considering the robber's location. |
void |
recalculateResourcesForRoll(SOCPlayerNumbers numbers,
int robberHex)
Calculate what resources this player will get on each die roll, optionally taking the robber into account. |
void |
recalculateRollsPerResource(SOCPlayerNumbers numbers,
int robberHex)
Calculate the rollsPerResource estimates, optionally considering the robber's location. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int ROAD
public static final int SETTLEMENT
public static final int CITY
public static final int CARD
public static final int SHIP
public static final int MIN
public static final int MAXPLUSONE
public static final int DEFAULT_ROLL_LIMIT
protected static boolean recalc
int[] estimatesFromNothing
int[] estimatesFromNow
private int[] rollsPerResource
SOCResourceConstants.CLAY
to SOCResourceConstants.WOOD
).
Index 0 is unused.
Does not contain GOLD_HEX
or SOCResourceConstants.GOLD_LOCAL
,
because SOCPlayerNumbers
methods translate the gold hexes into
each of the normal 5 resource types.
private SOCResourceSet[] resourcesForRoll
Does not contain GOLD_HEX
or SOCResourceConstants.GOLD_LOCAL
,
because SOCPlayerNumbers
methods translate each gold hex number
into 1 resource of each of the normal 5 types.
Constructor Detail |
---|
public SOCBuildingSpeedEstimate(SOCPlayerNumbers numbers)
numbers
- the numbers that the player's pieces are touchingpublic SOCBuildingSpeedEstimate()
recalculateEstimates(SOCPlayerNumbers, int)
.
Method Detail |
---|
public static final int[] getRollsForResourcesSorted(SOCPlayer pl)
pl.getNumbers()
,
and call getRollsPerResource()
.
pl
- Player to check numbers
SOCResourceConstants.CLAY
,
SOCResourceConstants.WHEAT
, etc,
where the resource in [0] has the highest rolls per resource.public int[] getEstimatesFromNothingAccurate(boolean[] ports)
ports
- the port flags for the player
public int[] getEstimatesFromNothingFast(boolean[] ports)
ports
- the port flags for the player
public int[] getEstimatesFromNothingFast(boolean[] ports, int limit)
ports
- the port flags for the player
public int[] getEstimatesFromNowAccurate(SOCResourceSet resources, boolean[] ports)
resources
- the player's current resourcesports
- the player's port flags
public int[] getEstimatesFromNowFast(SOCResourceSet resources, boolean[] ports)
resources
- the player's current resourcesports
- the player's port flags
public void recalculateEstimates(SOCPlayerNumbers numbers)
numbers
- the numbers that the player is touchingrecalculateEstimates(SOCPlayerNumbers, int)
public void recalculateEstimates(SOCPlayerNumbers numbers, int robberHex)
numbers
- the numbers that the player is touchingrobberHex
- Robber location from SOCBoard.getRobberHex()
,
or -1 to ignore the robberrecalculateEstimates(SOCPlayerNumbers)
public void recalculateRollsPerResource(SOCPlayerNumbers numbers, int robberHex)
numbers
- the numbers that the player is touchingrobberHex
- Robber location from SOCBoard.getRobberHex()
,
or -1 to ignore the robberpublic void recalculateResourcesForRoll(SOCPlayerNumbers numbers, int robberHex)
numbers
- the numbers that the player is touchingrobberHex
- Robber location from SOCBoard.getRobberHex()
,
or -1 to ignore the robberpublic int[] getRollsPerResource()
SOCResourceConstants.CLAY
to SOCResourceConstants.WOOD
).
Does not contain GOLD_HEX
or SOCResourceConstants.GOLD_LOCAL
,
because SOCPlayerNumbers
methods translate the gold hexes into
each of the normal 5 resource types.
protected final int calculateRollsFast(SOCResourceSet startingResources, SOCResourceSet targetResources, int cutoff, boolean[] ports)
This method does the same calculation as
calculateRollsAndRsrcFast(SOCResourceSet, SOCResourceSet, int, boolean[])
with a simpler return type and no thrown exception.
startingResources
- the starting resourcestargetResources
- the target resourcescutoff
- maximum number of rollsports
- a list of port flags
cutoff
if that maximum is reached.
If startingResources.contains(targetResources)
,
returns 0.protected SOCResSetBuildTimePair calculateRollsAndRsrcFast(SOCResourceSet startingResources, SOCResourceSet targetResources, int cutoff, boolean[] ports) throws CutoffExceededException
Before v2.0.00, this was calculateRollsFast
.
startingResources
- the starting resourcestargetResources
- the target resourcescutoff
- throw an exception if the total speed is greater than thisports
- a list of port flags
startingResources.contains(targetResources)
,
returns 0 rolls and a copy of startingResources
with identical amounts.
CutoffExceededException
- if total number of rolls > cutoff
calculateRollsFast(SOCResourceSet, SOCResourceSet, int, boolean[])
protected SOCResSetBuildTimePair calculateRollsAccurate(SOCResourceSet startingResources, SOCResourceSet targetResources, int cutoff, boolean[] ports) throws CutoffExceededException
startingResources
- the starting resourcestargetResources
- the target resourcescutoff
- throw an exception if the total speed is greater than thisports
- a list of port flags
startingResources.contains(targetResources)
,
returns 0 rolls and a null
resource set.
CutoffExceededException
- if estimate more than cutoff
turns to obtain targetResources
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |