Package net.sf.freecol.common.model
Class Map.MoveCandidate
- java.lang.Object
-
- net.sf.freecol.common.model.Map.MoveCandidate
-
- Enclosing class:
- Map
private static class Map.MoveCandidate extends java.lang.Object
Internal class for evaluating a candidate move.
-
-
Constructor Summary
Constructors Constructor Description MoveCandidate(Unit unit, PathNode current, Location dst, int movesLeft, int turns, boolean onCarrier, CostDecider decider)
Creates a new move candidate where a cost decider will be used to work out the new moves and turns left.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
add(java.util.HashMap<java.lang.String,PathNode> openMap, java.util.PriorityQueue<PathNode> openMapQueue, java.util.HashMap<java.lang.String,java.lang.Integer> f, Map.SearchHeuristic sh)
Add this candidate to the open map+queue.boolean
canImprove(PathNode best)
Does this move candidate improve on a specified move.void
embarkUnit(Unit unit)
Handles the change of unit as a result of an embark.int
getCost()
Get the cost.void
improve(java.util.HashMap<java.lang.String,PathNode> openMap, java.util.PriorityQueue<PathNode> openMapQueue, java.util.HashMap<java.lang.String,java.lang.Integer> f, Map.SearchHeuristic sh)
Replace a given path with that of this candidate move.java.lang.String
toString()
-
-
-
Constructor Detail
-
MoveCandidate
public MoveCandidate(Unit unit, PathNode current, Location dst, int movesLeft, int turns, boolean onCarrier, CostDecider decider)
Creates a new move candidate where a cost decider will be used to work out the new moves and turns left.- Parameters:
unit
- TheUnit
to move.current
- The current position on the path.dst
- TheLocation
to move to.movesLeft
- The initial number of moves left.turns
- The initial number of turns.onCarrier
- Will the new move be on a carrier.decider
- TheCostDecider
to use.
-
-
Method Detail
-
getCost
public int getCost()
Get the cost.- Returns:
- The current move cost.
-
embarkUnit
public void embarkUnit(Unit unit)
Handles the change of unit as a result of an embark.- Parameters:
unit
- TheUnit
to embark.
-
canImprove
public boolean canImprove(PathNode best)
Does this move candidate improve on a specified move.- Parameters:
best
- ThePathNode
to compare against.- Returns:
- True if this candidate is an improvement.
-
improve
public void improve(java.util.HashMap<java.lang.String,PathNode> openMap, java.util.PriorityQueue<PathNode> openMapQueue, java.util.HashMap<java.lang.String,java.lang.Integer> f, Map.SearchHeuristic sh)
Replace a given path with that of this candidate move.- Parameters:
openMap
- The list of available nodes.openMapQueue
- The queue of available nodes.f
- The heuristic values for A*.sh
- ASearchHeuristic
to apply.
-
add
public void add(java.util.HashMap<java.lang.String,PathNode> openMap, java.util.PriorityQueue<PathNode> openMapQueue, java.util.HashMap<java.lang.String,java.lang.Integer> f, Map.SearchHeuristic sh)
Add this candidate to the open map+queue.- Parameters:
openMap
- The list of available nodes.openMapQueue
- The queue of available nodes.f
- The map of f-values.sh
- ASearchHeuristic
to apply.
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-