de.uni_paderborn.robots.robot.group10
Class Map.ShortestPath

java.lang.Object
  |
  +--de.uni_paderborn.robots.robot.group10.Map.ShortestPath
Enclosing class:
Map

public class Map.ShortestPath
extends java.lang.Object

Class for storing paths created by Map.findShortestPath()


Field Summary
protected  int distance
          The distance to the end of this path.
protected  int flags
          The flags used to create this path.
protected  MapItemMatcher mapItemMatcher
          The MapItemMatcher used to create this path.
protected  int notVisitedRetries
          The number of unsuccessful tries to walk a path containing NOT_VISITED MapItems is counted here.
protected  java.util.LinkedList pathToItem
          A list of MapItems representing the path.
protected  boolean wormholeUsed
          Set to true when the roboter has just used a wormhole.
 
Constructor Summary
Map.ShortestPath(MapItemMatcher mapItemMatcher, java.util.LinkedList pathToItem, int distance, int flags)
          Constructor of a new ShortestPath object
 
Method Summary
 int getDistance()
          Returns the distance left to the map item which the robot is currently going to using stepToNearestItem().
 boolean isValid()
          Checks whether this path is still usable for the robot or he has to search a new path.
 AbstractRobotAction nextStep()
          Returns the next step on this path.
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

pathToItem

protected java.util.LinkedList pathToItem
A list of MapItems representing the path. Whenever the robot makes a step on the path, the first element is removed.

distance

protected int distance
The distance to the end of this path.

mapItemMatcher

protected MapItemMatcher mapItemMatcher
The MapItemMatcher used to create this path.

flags

protected int flags
The flags used to create this path. May be any combination of USE_NOT_VISITED, DONT_USE_RECENT_CARDS and STOP_IN_FRONT_OF_ITEM.

wormholeUsed

protected boolean wormholeUsed
Set to true when the roboter has just used a wormhole.

notVisitedRetries

protected int notVisitedRetries
The number of unsuccessful tries to walk a path containing NOT_VISITED MapItems is counted here. Unsuccessful tries means that the robot found a wall on its path.
Constructor Detail

Map.ShortestPath

public Map.ShortestPath(MapItemMatcher mapItemMatcher,
                        java.util.LinkedList pathToItem,
                        int distance,
                        int flags)
Constructor of a new ShortestPath object
Parameters:
mapItemMatcher - reference to the MapItemMatcher
pathToItem - reference to the LinksList
distance - int-value of the distance
flags - {
Method Detail

getDistance

public int getDistance()
Returns the distance left to the map item which the robot is currently going to using stepToNearestItem(). This value may by incorrect by 1 because this method does not care about the direction the robot currently has.
Returns:
the distance the map item stepToNearestItem() goes to.

isValid

public boolean isValid()
Checks whether this path is still usable for the robot or he has to search a new path.
Returns:
false if the path cannot be used any more

nextStep

public AbstractRobotAction nextStep()
Returns the next step on this path.
Returns:
An AbstractRobotAction that is either a MoveAction or a RotateAction or null if there was an error. To get more information about the error, use getPathError().