|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectnet.sf.freecol.common.model.PathNode
public class PathNode
Represents a single Tile in a path.
You will most likely be using: next, getDirection(),
getTile() and getTotalTurns(), when evaluating/following a path.
| Field Summary | |
|---|---|
private int |
cost
|
private Map.Direction |
direction
|
private int |
f
This is cost + heuristics. |
private int |
movesLeft
|
PathNode |
next
The next node in the path. |
private boolean |
onCarrier
|
PathNode |
previous
The previous node in the path. |
private Tile |
tile
|
private int |
turns
|
| Constructor Summary | |
|---|---|
PathNode(Tile tile,
int cost,
int f,
Map.Direction direction,
int movesLeft,
int turns)
Creates a new PathNode. |
|
| Method Summary | |
|---|---|
int |
compareTo(PathNode o)
Compares this PathNode's f with the
f of the given object. |
boolean |
equals(java.lang.Object o)
Checks if this PathNode is equal to another object. |
java.lang.String |
fullPathToString()
Another debug helper. |
int |
getCost()
Returns the cost of moving to this PathNode's tile. |
Map.Direction |
getDirection()
Returns the direction to move in order to get closer towards the goal. |
int |
getF()
Returns the estimated cost of the path at this stage. |
PathNode |
getLastNode()
Returns the last node of this path. |
int |
getMovesLeft()
Returns the number of moves remaining at this point in the path. |
Tile |
getTile()
Gets the Tile of this PathNode. |
int |
getTotalTurns()
Returns the number of turns it will take to move the entire path, from the starting PathNode until the end. |
PathNode |
getTransportDropNode()
Returns the node where the unit using this path should leave its transport. |
int |
getTransportDropTurns()
Returns the number of turns it takes to reach the transport node. |
int |
getTurns()
Returns the number of turns it will take to reach this PathNode's Tile in the path. |
int |
hashCode()
Returns the hashCode of this object. |
boolean |
isOnCarrier()
Checks if the unit using this path is still onboard its transport. |
void |
setMovesLeft(int movesLeft)
Sets the number of moves remaining at this point in the path. |
void |
setOnCarrier(boolean onCarrier)
Sets if the unit using this path is still onboard its transport. |
java.lang.String |
toString()
Debug helper. |
| Methods inherited from class java.lang.Object |
|---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
private Tile tile
private int cost
private int f
cost + heuristics. The latter one is an estimate
for the cost from this tile and to the goal.
private Map.Direction direction
private int movesLeft
private int turns
private boolean onCarrier
public PathNode next
public PathNode previous
| Constructor Detail |
|---|
public PathNode(Tile tile,
int cost,
int f,
Map.Direction direction,
int movesLeft,
int turns)
PathNode.
tile - The Tile this PathNode
represents in the path.cost - The cost of moving to this PathNode's
Tile, given in Unit.getMovesLeft()
move points.f - This is cost + heuristics. The latter one is
an estimate for the cost from this Tile and
to the goal.direction - The direction to move on the map in order to
get to the next Tile in the path.movesLeft - The number of moves remaining at this point in the path.turns - The number of turns it takes to reach this
PathNode's Tile from the
start of the path.| Method Detail |
|---|
public int getCost()
PathNode's tile.
PathNode's
Tile, given in Unit.getMovesLeft()
move points.public Tile getTile()
Tile of this PathNode.
Tile you reach if you move in the direction
given by getDirection() from the previous tile. Explained by code:
map.getNeighbourOrNull(getDirection(),
previous.getTile()) == getTile()
Tile this PathNode
represents in the path.public boolean isOnCarrier()
true if the unit is still onboard a
carrier when using this path.getTransportDropTurns()public void setOnCarrier(boolean onCarrier)
onCarrier - Should be set to true in order to
indicate that the unit using this path is still onboard
the carrier on this path node.getTransportDropTurns()public int getTransportDropTurns()
transport node.
public PathNode getTransportDropNode()
public PathNode getLastNode()
PathNode.public int getF()
cost + heuristics. The latter one is
an estimate for the cost from this tile
and to the goal.public Map.Direction getDirection()
Tile returned by this PathNode's
getTile() in the path.public int getTurns()
PathNode's Tile in the path.
-1 is returned if the number of
turns has not been calculated.public int getTotalTurns()
PathNode until the end.
public int getMovesLeft()
-1 is
returned if the number of moves left has not been calculated.public void setMovesLeft(int movesLeft)
movesLeft - The number of moves remaining.public int compareTo(PathNode o)
PathNode's f with the
f of the given object.
compareTo in interface java.lang.Comparable<PathNode>o - the object to be compared.
java.lang.ClassCastException - if the given object is not a
PathNode.public boolean equals(java.lang.Object o)
PathNode is equal to another object.
equals in class java.lang.Objecto - The Object to compare with.
true if the given object is a
PathNode with the same getTile()
tile as this one.public int hashCode()
hashCode in class java.lang.Objectpublic java.lang.String toString()
toString in class java.lang.Objectpublic java.lang.String fullPathToString()
A - string describing the whole path.
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||