dip.process
Class RetreatChecker

java.lang.Object
  extended bydip.process.RetreatChecker

public class RetreatChecker
extends java.lang.Object

RetreatChecker analyzes the current TurnState and the results of the previous TurnState to determine which (if any) retreat locations are acceptable for a retreating unit. Thus it is only dependent upon the adjudication results, and the current Position.

Basic Retreat Algorithm:

Should be threadsafe.


Constructor Summary
RetreatChecker(TurnState current)
          Create a RetreatChecker.
RetreatChecker(TurnState current, java.util.List previousTurnStateResults)
          Create a RetreatChecker.
 
Method Summary
 Location[] getValidLocations(Location from)
          Gets all valid locations to which this unit may retreat.
 boolean hasRetreats(Location from)
          Returns 'true' if at least one valid retreat exists for the dislodged unit in 'from'
 boolean isValid(Location from, Location to)
          Determines if the unit located in from can retreat to the Location to
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RetreatChecker

public RetreatChecker(TurnState current)
Create a RetreatChecker.

There must be at least one prior TurnState in the World object for this to work, however, if we a unit is Dislodged and it is the very first TurnState (this can happen if the game is edited), it is allowed.


RetreatChecker

public RetreatChecker(TurnState current,
                      java.util.List previousTurnStateResults)
Create a RetreatChecker.

Useful for when the previous TurnState has not yet been inserted into the World object.

Method Detail

isValid

public boolean isValid(Location from,
                       Location to)
Determines if the unit located in from can retreat to the Location to


getValidLocations

public Location[] getValidLocations(Location from)
Gets all valid locations to which this unit may retreat.

Returns a zero-length array if there are no acceptable retreat locations.


hasRetreats

public boolean hasRetreats(Location from)
Returns 'true' if at least one valid retreat exists for the dislodged unit in 'from'



Copyright 2002-2004 Zachary DelProposto / jDip Development Team. All Rights Reserved.