Class DijkstraMoveCalculator

  extended bycivquest.units.MoveCalculator
      extended bycivquest.units.DijkstraMoveCalculator

public class DijkstraMoveCalculator
extends MoveCalculator

Nested Class Summary
 class DijkstraMoveCalculator.FieldInfoComparator
          Comparator for comparing two FieldInfo-objects (needed for the heap used within the dijkstra-algorithm).
Constructor Summary
DijkstraMoveCalculator(Registry registry)
Method Summary
 MovePath calculateOneMovePath(java.util.Collection unitCollection, Field to)
          Calculates a MovePath for a move of the given unit-group from its current position to Field .
 boolean moveUnit(long id, Coordinate to)
          Moves the unit with the given id to field .
Methods inherited from class civquest.units.MoveCalculator
calculateMovePaths, constructUnitGroups
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Detail


public DijkstraMoveCalculator(Registry registry)
Method Detail


public boolean moveUnit(long id,
                        Coordinate to)
Moves the unit with the given id to field . A field with Coordinate must exist (no test on this is performed) and field must especially be a neighborfield of the field the unit is currently located on (a test on this is performed, see below). A unit with id must exist. Performes all necessary datastructure-updates. Especially, this function takes into account the time the unit has left this turn, its speed and its distance to field . If uncomplete moves are allowed, the unit may have started a move to some neighbor-field, this will be taken into account. If time doesn't suffice, dependend on areIncompleteMovesAllowed (AIMA), the following two cases exist: AIMA = true: The timeAwayFromSourceField and incompleteMoveDestField- attributes are set correctly AIMA = false: If the unit hasn't moved up to now this turn, it can move to nevertheless. Otherwise, it cannot move at all, so all relevant datastructures remain unchanged. NOTE: None of the cases described above is a reason for returning false The function tests for being a neighbor-field (case EA), existence of unit (case EB).

Specified by:
moveUnit in class MoveCalculator
id - unit-id as described
to - field to move to
false, if one of the (error-) cases EA, EB happened, true otherwise


public MovePath calculateOneMovePath(java.util.Collection unitCollection,
                                     Field to)
Calculates a MovePath for a move of the given unit-group from its current position to Field .

Specified by:
calculateOneMovePath in class MoveCalculator
to - a Field
a MovePath as described