net.sf.freecol.common.model.pathfinding
Class BaseCostDecider
java.lang.Object
net.sf.freecol.common.model.pathfinding.BaseCostDecider
- All Implemented Interfaces:
- CostDecider
- Direct Known Subclasses:
- AvoidBlockingUnitsCostDecider
class BaseCostDecider
- extends java.lang.Object
- implements CostDecider
Class for determining the cost of a single move.
This CostDecider is used as a default by
findPath and
search
if no other CostDecider has been specified.
|
Method Summary |
int |
getCost(Unit unit,
Tile oldTile,
Tile newTile,
int movesLeftBefore,
int turns)
Determines the cost of a single move. |
int |
getMovesLeft()
Gets the number of moves left. |
boolean |
isNewTurn()
Checks if a new turn is needed in order to make the
move. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
movesLeft
private int movesLeft
newTurn
private boolean newTurn
moveType
protected Unit.MoveType moveType
BaseCostDecider
BaseCostDecider()
getCost
public int getCost(Unit unit,
Tile oldTile,
Tile newTile,
int movesLeftBefore,
int turns)
- Determines the cost of a single move.
- Specified by:
getCost in interface CostDecider
- Parameters:
unit - The Unit making the move.oldTile - The Tile we are moving from.newTile - The Tile we are moving to.movesLeftBefore - The moves left before making the move.turns - The number of turns spent so far.
- Returns:
- The cost of moving the given unit from the
oldTile to the newTile.
getMovesLeft
public int getMovesLeft()
- Gets the number of moves left. This method should be
called after invoking
getCost(net.sf.freecol.common.model.Unit, net.sf.freecol.common.model.Tile, net.sf.freecol.common.model.Tile, int, int).
- Specified by:
getMovesLeft in interface CostDecider
- Returns:
- The number of moves left.
isNewTurn
public boolean isNewTurn()
- Checks if a new turn is needed in order to make the
move. This method should be called after invoking
getCost(net.sf.freecol.common.model.Unit, net.sf.freecol.common.model.Tile, net.sf.freecol.common.model.Tile, int, int).
- Specified by:
isNewTurn in interface CostDecider
- Returns:
true if the move requires a
new turn and false otherwise.