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.ObjectInternal 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 voidadd(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.booleancanImprove(PathNode best)Does this move candidate improve on a specified move.voidembarkUnit(Unit unit)Handles the change of unit as a result of an embark.intgetCost()Get the cost.voidimprove(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.StringtoString()
-
-
-
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- TheUnitto move.current- The current position on the path.dst- TheLocationto 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- TheCostDeciderto 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- TheUnitto embark.
-
canImprove
public boolean canImprove(PathNode best)
Does this move candidate improve on a specified move.- Parameters:
best- ThePathNodeto 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- ASearchHeuristicto 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- ASearchHeuristicto apply.
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-