de.uni_paderborn.robots.robot.group9
Class Map

java.lang.Object
  |
  +--de.uni_paderborn.robots.robot.group9.Map

public class Map
extends java.lang.Object

Automatically creates a map of the arena while the robot walks through it.


Inner Class Summary
 class Map.Coordinate
          Stores x and y coordinates, area information (used when robot uses a teleport).
private  class Map.DijDistanceComparator
          Class that implements an order for MapItems based on their BfsDistance.
 class Map.ShortestPath
          Class for storing paths created by findShortestPath
 
Field Summary
static int ALREADY_THERE
          Error code returned by getPathError().
private  int areaCounter
          Count the number of newly found areas
private  boolean areasJoined
          Is set to true exactly in the round, in which two different areas could be joined because a position had been found that is common to both areas.
private  java.util.HashSet badReactableClasses
          Stores the Class objects of all reactables that cause harm to a robot.
private  MapItem cachedCurrentMapItem
          For caching the map item the robot currently sits on.
private  MapItem cachedMapItemInFront
          For caching the map item the robot currenty looks at.
static int CARD_BLOCKS
          Error code returned by getPathError().
(package private) static int DONT_USE_RECENT_CARDS
          Flag for findShortestPath():
During searching the path do not go over cards the robot has found during the last 10 rounds.
static int ENERGY_TOLERANCE
          The robot won't try to go paths that are not within getEnergy() - ENERGY_TOLERANCE
private  boolean energyKnown
          Is set to true when robot finds an energy source (well)
private  int energyPreUnknownReactable
          Records the energy of a robot directly before the robot tries the effect of an unknown reactable
private  boolean exitKnown
          Is set to true when robot finds the exit
private  int gameRound
          Stores the number of the game round currently in progress.
private  int horizontalCycleSize
          Stores the size of a horizontal cycle in the arena.
static int INVALID
          Error code returned by getPathError() This path does not is not valid any more
private  java.util.Hashtable itemCoordinateTable
          Datastructure to keep all map items quickly accessible by their coordinate
private  java.util.TreeMap itemTreeMap
          Datastructure to keep all map items quickly accessible by their id
static int MAX_DISTANCE_EXCEEDED
          Error code returned by getPathError().
static int NOT_FOUND
          Error code returned by getPathError().
static int OKAY
          Error code returned by getPathError().
private  int pathError
          If any of the methods dealing with shortest paths fails, it sets this value to an error code explaing the reason of the failure.
private  int postTeleportUsageState
          For internal use of postTeleportUsage().
static int PROGRAM_BUG
          Error code returned by getPathError().
private  java.util.Random rand
          Random number generator used by the shortest path methods.
private  LAR robot
          The robot that uses this map
static int ROBOT_BLOCKS
          Error code returned by getPathError().
private  int sawKnownFields
          For keeping statistics, how many fields have been sawn more than once, and thus redundantly.
private  int sizeOfPortablePreUnknownReactable
          Records the size of the robot's portable directly before the robot tries the effect of an unknwon reactable
static int SLEEPING_ROBOT_BLOCKS
          Error code returned by getPathError().
private  int stepsToWell
          The distance to the next well estimated by isWellGettingFar()
(package private) static int STOP_IN_FRONT_OF_ITEM
          Flag for findShortestPath():
Does not go directly onto field which contains the item, but stops in front of it, when the robot looks at it.
static int TELEPORT_WAS_BLOCKED
          Error code returned by getPathError(): The used teleporter was blocked.
private  boolean teleporterKnown
          Is set to true when robot finds a teleporter
static int UNEXPECTED_OBSTACLE
          Error code returned by getPathError(): There was an unexpected obstacle in the calculated way.
private  boolean unknownReactableKnown
          Is set to true when robot finds an unknown reactable
static int UNUSED_TELEPORTS
          Error code returned by getPathError(): There are no unknown fields, but unused teleports
(package private) static int USE_NOT_VISITED
          Flag for findShortestPath():
Also used fields marked as NOT_VISITED during the search.
private  MapItem usedTeleport
          usesTeleport() stores here the teleport to be used.
private  MapItem usedUnknownReactable
          The MapItem of the unknown reactable that the robot is about to use is stored here.
private  int verticalCycleSize
          Stores the size of a vertical cycle in the arena.
static int VIA_WELL
          Error code returned by getPathError().
private  int whenCheck
          This value determines how often the shortest path to the well is actually calculated by isWellGettingFar() and not estimated.
 
Constructor Summary
Map()
          Creates and initializes a new map object
 
Method Summary
private  int addAdjacentItemsToQueue(MapItem mapItem, int predecessorDirection, MapItemMatcher mapItemMatcher, java.util.TreeSet queue, int addedToQueue)
          Adds add items linked to the given mapItem to the priority queue of the dijstra algorithm.
 void addMapItem(MapItem mapItem)
          Add a MapItem to the internal lists.
private  void checkCyclicArena(MapItem mapItemHere, MapItem mapItemInFront)
          Checks whether the MapItem the robot sits on and the MapItem the robot looks at indicates a cyclic arena.
 MapItem findMapItemByCoordinate(Map.Coordinate coordinate)
          Searches all known map items for the map item with the given coordinate
 MapItem findMapItemById(int id)
          Searches all known map items for the map item with the given id
 Map.ShortestPath findShortestPath(MapItemMatcher mapItemMatcher, int maxDistance, int flags)
          Tries to find a shortest path that is at most maxDistance steps long to a map item that can be specified using the mapItemMatcher.
 MapItem getCurrentMapItem()
          Returns the map item the robot currently sits on.
 int getGameRound()
          Get the number of the game round currently in progress.
 int getHorizontalCycleSize()
          Read access method for horizontalCycleSize
 MapItem getMapItemBehind()
          Returns the map item behind of the robot (relative to robot's direction).
 MapItem getMapItemInFront()
          Returns the map item the robot currently looks at.
 MapItem getMapItemLeft()
          Returns the map item to the left of the robot (relative to robot's direction).
 MapItem getMapItemRight()
          Returns the map item to the right of the robot (relative to robot's direction).
 int getPathError()
          If any of the methods dealing with shortest paths fails, this method can be used to obtain an error code explaing the reason of the failure.
 LAR getRobot()
          Get the robot that uses this map.
 int getVerticalCycleSize()
          Read access method for verticalCycleSize
 boolean isBadReactableClass(java.lang.Class itemClass)
          Checks using "empiric data" stored in badReactableClasses whether this reactable class is known to cause harm to a robot
 boolean isEnergyKnown()
          Checks whether the robot has already found an energy source (well) during the arena exploration.
 boolean isExitKnown()
          Checks whether the robot has already found the exit during the arena exploration.
 boolean isTeleporterKnown()
          Checks whether the robot has already found a teleporter during the arena exploration.
 boolean isUnknownReactableKnown()
          Checks whether the robot has already found a reactable that is not a telporter, card, well or exit during the arena exploration.
 boolean isWellGettingFar()
          isWellGettingFar() tells the robot in a fast way, whether the next well is dangerously too far away.
private  void joinAreas(MapItem mapItemHere, MapItem mapItemInFront)
          joinAreas() is called when the trackPosition() Method finds two neigbour fields which belong to different mapping areas.
private  void joinMapItemLinks(MapItem mapItem, MapItem mapItemRemove)
          Joins two MapItems into one.
static int oppositeDirection(int direction)
          Rotates a given direction value as defined in Robot.java by 180 degrees Thus, north would become south.
private  java.util.LinkedList performDij(MapItemMatcher mapItemMatcher, MapItem startMapItem, int maxDistance, int flags)
          Searches for the nearest map item that matches with the specified search criteria.
 AbstractAction postTeleportUsage()
          This method tells the map that the robot has just passed a teleport.
 void postUnknownReactableUsage()
          Checks whether the reactable that was just used by the robot has caused any damage.
 boolean preTeleportUsage()
          This method tells the map that the robot is about to use a teleport.
 void preUnknownReactableUsage()
          Records the energy and the portable-size of the robot when the robot is about to use an unknown reactable.
 void printMap()
          Debug code: Prints an ASCII version of the map to the terminal
 void removeMapItem(MapItem mapItem)
          Removes a given MapItem from the internal lists.
static int rotateDirectionLeft(int direction)
          Rotates a given direction value as defined in Robot.java by 90 degrees to the left.
static int rotateDirectionRight(int direction)
          Rotates a given direction value as defined in Robot.java by 90 degrees to the right.
 void setHorizontalCycleSize(int horizontalCycleSize)
          Write access method for horizontalCycleSize
 void setRobot(LAR robot)
          Set the robot that uses this map.
 void setVerticalCycleSize(int verticalCycleSize)
          Write access method for verticalCycleSize
 void setWhenCheck(int whenCheck)
          Write access method for attribute whenCheck
 boolean teleportHasBeenUsed()
          Determines using map internal data whether the robot has used a teleporter in the previous round.
 void trackPosition()
          Creates the map of the arena.
 Map.ShortestPath unknownFields()
          Checks whether there are still unknown fields in the arena.
private  void updateSurroundingMapItems(MapItem mapItem, int notThisDirection)
          Checks the neighbour MapItems of the specified one.
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

robot

private LAR robot
The robot that uses this map

sawKnownFields

private int sawKnownFields
For keeping statistics, how many fields have been sawn more than once, and thus redundantly.

gameRound

private int gameRound
Stores the number of the game round currently in progress.

exitKnown

private boolean exitKnown
Is set to true when robot finds the exit

energyKnown

private boolean energyKnown
Is set to true when robot finds an energy source (well)

teleporterKnown

private boolean teleporterKnown
Is set to true when robot finds a teleporter

unknownReactableKnown

private boolean unknownReactableKnown
Is set to true when robot finds an unknown reactable

verticalCycleSize

private int verticalCycleSize
Stores the size of a vertical cycle in the arena. Is -1 if there is no vertical cycle or non has been found, yet.

horizontalCycleSize

private int horizontalCycleSize
Stores the size of a horizontal cycle in the arena. Is -1 if there is no horizontal cycle or non has been found, yet.

cachedCurrentMapItem

private MapItem cachedCurrentMapItem
For caching the map item the robot currently sits on. Before using, always check the id of the map item to be correct. currentMapItem may be also null

cachedMapItemInFront

private MapItem cachedMapItemInFront
For caching the map item the robot currenty looks at.

itemTreeMap

private java.util.TreeMap itemTreeMap
Datastructure to keep all map items quickly accessible by their id

itemCoordinateTable

private java.util.Hashtable itemCoordinateTable
Datastructure to keep all map items quickly accessible by their coordinate

areasJoined

private boolean areasJoined
Is set to true exactly in the round, in which two different areas could be joined because a position had been found that is common to both areas. Used by the shortest path methods, because the "knowledge" of the robot changes in such a situation

areaCounter

private int areaCounter
Count the number of newly found areas

pathError

private int pathError
If any of the methods dealing with shortest paths fails, it sets this value to an error code explaing the reason of the failure.

OKAY

public static final int OKAY
Error code returned by getPathError(). Everything is fine

NOT_FOUND

public static final int NOT_FOUND
Error code returned by getPathError(). A map item with the given specifications could not be found. Only generated if maxDistance is infinite (-1).

MAX_DISTANCE_EXCEEDED

public static final int MAX_DISTANCE_EXCEEDED
Error code returned by getPathError(). A map item with the given specifications could not be found in the given maximum distance.

ROBOT_BLOCKS

public static final int ROBOT_BLOCKS
Error code returned by getPathError(). Another robot blocks the way. See also SLEEPING_ROBOT_BLOCKS.

SLEEPING_ROBOT_BLOCKS

public static final int SLEEPING_ROBOT_BLOCKS
Error code returned by getPathError(). A robot without energy blocks the way.

CARD_BLOCKS

public static final int CARD_BLOCKS
Error code returned by getPathError(). A card blocks the way.

ALREADY_THERE

public static final int ALREADY_THERE
Error code returned by getPathError(). You already reached the requested position.

INVALID

public static final int INVALID
Error code returned by getPathError() This path does not is not valid any more

VIA_WELL

public static final int VIA_WELL
Error code returned by getPathError(). The requested destination is only reachable via an energy source. This code is currently not generated.

UNUSED_TELEPORTS

public static final int UNUSED_TELEPORTS
Error code returned by getPathError(): There are no unknown fields, but unused teleports

UNEXPECTED_OBSTACLE

public static final int UNEXPECTED_OBSTACLE
Error code returned by getPathError(): There was an unexpected obstacle in the calculated way. This can be caused by a teleport that put the robot on a disadvanteous side of the teleport or by using the USE_UNKNOWN_FIELDS flag

TELEPORT_WAS_BLOCKED

public static final int TELEPORT_WAS_BLOCKED
Error code returned by getPathError(): The used teleporter was blocked.

PROGRAM_BUG

public static final int PROGRAM_BUG
Error code returned by getPathError(). The programmer of this code f*cked up.

rand

private java.util.Random rand
Random number generator used by the shortest path methods. Different paths with the same (shortest) length are chosen randomly to bring some life into the actions. ;)

STOP_IN_FRONT_OF_ITEM

static final int STOP_IN_FRONT_OF_ITEM
Flag for findShortestPath():
Does not go directly onto field which contains the item, but stops in front of it, when the robot looks at it. Should be used e.g. for Cards

USE_NOT_VISITED

static final int USE_NOT_VISITED
Flag for findShortestPath():
Also used fields marked as NOT_VISITED during the search. That may cause that the robot has to recalculate the path when it finds that NOT_VISITED field was a wall or similar

DONT_USE_RECENT_CARDS

static final int DONT_USE_RECENT_CARDS
Flag for findShortestPath():
During searching the path do not go over cards the robot has found during the last 10 rounds.

usedTeleport

private MapItem usedTeleport
usesTeleport() stores here the teleport to be used.

postTeleportUsageState

private int postTeleportUsageState
For internal use of postTeleportUsage(). Keeps track whether the robot has aready turned to look at the teleport, etc.

energyPreUnknownReactable

private int energyPreUnknownReactable
Records the energy of a robot directly before the robot tries the effect of an unknown reactable

sizeOfPortablePreUnknownReactable

private int sizeOfPortablePreUnknownReactable
Records the size of the robot's portable directly before the robot tries the effect of an unknwon reactable

usedUnknownReactable

private MapItem usedUnknownReactable
The MapItem of the unknown reactable that the robot is about to use is stored here.

badReactableClasses

private java.util.HashSet badReactableClasses
Stores the Class objects of all reactables that cause harm to a robot.

stepsToWell

private int stepsToWell
The distance to the next well estimated by isWellGettingFar()

whenCheck

private int whenCheck
This value determines how often the shortest path to the well is actually calculated by isWellGettingFar() and not estimated. It is calculated when gameRound = 0 mod whenCheck.

ENERGY_TOLERANCE

public static final int ENERGY_TOLERANCE
The robot won't try to go paths that are not within getEnergy() - ENERGY_TOLERANCE
Constructor Detail

Map

public Map()
Creates and initializes a new map object
Method Detail

setRobot

public void setRobot(LAR robot)
Set the robot that uses this map.

Parameters:
robot - the robot that uses this map

getRobot

public LAR getRobot()
Get the robot that uses this map.

Returns:
the robot that uses this map

getGameRound

public int getGameRound()
Get the number of the game round currently in progress. Round numbers start couting at 1, thus numbers <= 0 are not valid round numbers and can be used for special cases in other contexts.
Returns:
number of current round

isExitKnown

public boolean isExitKnown()
Checks whether the robot has already found the exit during the arena exploration.

Returns:
true if exit has already been found

isEnergyKnown

public boolean isEnergyKnown()
Checks whether the robot has already found an energy source (well) during the arena exploration.

Returns:
true if an energy source has already been found

isTeleporterKnown

public boolean isTeleporterKnown()
Checks whether the robot has already found a teleporter during the arena exploration.

Returns:
true if a teleporter has already been found

isUnknownReactableKnown

public boolean isUnknownReactableKnown()
Checks whether the robot has already found a reactable that is not a telporter, card, well or exit during the arena exploration. (I know, that knowing something unknown is not entirely logical, but for the consistency's sake ...)

Returns:
true if an unknown reactable has already been found

getVerticalCycleSize

public int getVerticalCycleSize()
Read access method for verticalCycleSize
Returns:
the value of verticalCycleSize

setVerticalCycleSize

public void setVerticalCycleSize(int verticalCycleSize)
Write access method for verticalCycleSize
Parameters:
verticalCycleSize - the new value

getHorizontalCycleSize

public int getHorizontalCycleSize()
Read access method for horizontalCycleSize
Returns:
the value of horizontalCycleSize

setHorizontalCycleSize

public void setHorizontalCycleSize(int horizontalCycleSize)
Write access method for horizontalCycleSize
Parameters:
horizontalCycleSize - the new value

getCurrentMapItem

public MapItem getCurrentMapItem()
Returns the map item the robot currently sits on. This method is faster than findMapItemById(robot.getArena().getIdOfCurrentField(robot)) because this method uses currentMapItem to cache the current position of the robot.

Returns:
the map item the robot currently sits on.

getMapItemInFront

public MapItem getMapItemInFront()
Returns the map item the robot currently looks at. Like getCurrentMapItem(), this method also uses caching.

Returns:
the map item the robot currently looks at.

getMapItemLeft

public MapItem getMapItemLeft()
Returns the map item to the left of the robot (relative to robot's direction). Note that this map item may not reflect the current state of the item, but the state when this item was actually seen by the robot. Thus, the map item may be marked to contain a card, but the card could have been already taken away by another robot. If this method returns null, this position is not yet known.

getMapItemRight

public MapItem getMapItemRight()
Returns the map item to the right of the robot (relative to robot's direction). Note that this map item may not reflect the current state of the item, but the state when this item was actually seen by the robot. Thus, the map item may be marked to contain a card, but the card could have been already taken away by another robot. If this method returns null, this position is not yet known.

getMapItemBehind

public MapItem getMapItemBehind()
Returns the map item behind of the robot (relative to robot's direction). Note that this map item may not reflect the current state of the item, but the state when this item was actually seen by the robot. Thus, the map item may be marked to contain a card, but the card could have been already taken away by another robot. If this method returns null, this position is not yet known.

findMapItemById

public MapItem findMapItemById(int id)
Searches all known map items for the map item with the given id
Parameters:
id - the id to search for
Returns:
map item with the specified id or null if id is unknown

findMapItemByCoordinate

public MapItem findMapItemByCoordinate(Map.Coordinate coordinate)
Searches all known map items for the map item with the given coordinate
Parameters:
coordinate - the coordinate to search for
Returns:
map item with the specified coordinate or null if coordinate is unknown

addMapItem

public void addMapItem(MapItem mapItem)
Add a MapItem to the internal lists. Be careful not to modify the id and coordinate values of the MapItem while it is in the internal list. Thus, if you need to modify one of these values, call removeMapItem(), modify the value and then call addMapItem() again. The map item is not added to this Map's graph!
Parameters:
mapItem - The mapItem to be added

removeMapItem

public void removeMapItem(MapItem mapItem)
Removes a given MapItem from the internal lists. The MapItem is not removed from this Map's graph!
Parameters:
mapItem - The mapItem to be removed.

rotateDirectionLeft

public static int rotateDirectionLeft(int direction)
Rotates a given direction value as defined in Robot.java by 90 degrees to the left. Thus, north would become west.

Parameters:
direction - direction to be rotated
Returns:
direction rotated by 90 degrees to the left.

rotateDirectionRight

public static int rotateDirectionRight(int direction)
Rotates a given direction value as defined in Robot.java by 90 degrees to the right. Thus, north would become east.

Parameters:
direction - direction to be rotated
Returns:
direction rotated by 90 degrees to the right.

oppositeDirection

public static int oppositeDirection(int direction)
Rotates a given direction value as defined in Robot.java by 180 degrees Thus, north would become south.

Parameters:
direction - direction to be rotated

updateSurroundingMapItems

private void updateSurroundingMapItems(MapItem mapItem,
                                       int notThisDirection)
Checks the neighbour MapItems of the specified one. If the neighbour exists, the link between the MapItems is set, otherwise a new neighbour with type NOT_VISITED is created (unless if specified mapItem is of type NOT_VISITED).
Parameters:
mapItem - The MapItem to be surrounded.
notThisDirection - The link in the specified direction will not be changed.

joinMapItemLinks

private void joinMapItemLinks(MapItem mapItem,
                              MapItem mapItemRemove)
Joins two MapItems into one. This is done by taking the links to visited fields from one MapItem and putting these into the corresponding links of the other MapItem. Assumes that if one mapItem has links to a visited field in a direction, the other has no link to a visited field in that direction, because if this would have been the case, the area join operation would have been done before.
Parameters:
mapItem - a MapItem to join. This MapItem will stay (in joined state) in the Map graph
mapItemRemove - the oter MapItem to join. This MapItem will be after the joining removed from the Map graph

joinAreas

private void joinAreas(MapItem mapItemHere,
                       MapItem mapItemInFront)
joinAreas() is called when the trackPosition() Method finds two neigbour fields which belong to different mapping areas. A new mapping area is created when the roboter uses for example a teleporter and has thus no reference map item to link the newly created map to. When a link is found (the neighbour fields) this method joins the two areas to one.
Parameters:
mapItemHere - the MapItem the robot sits on
mapItemInFront - the MapItem the robot looks at, should be in another area than mapItemHere.

checkCyclicArena

private void checkCyclicArena(MapItem mapItemHere,
                              MapItem mapItemInFront)
Checks whether the MapItem the robot sits on and the MapItem the robot looks at indicates a cyclic arena. If so, the cycle is also created in the robot's map. Is called in each round by trackPosition().
Parameters:
mapItemHere - the MapItem the robot sits on
mapItemInFront - the MapItem the robot looks at.

trackPosition

public void trackPosition()
Creates the map of the arena. Takes care that after the use of teleporters the map is still consistent and the two disjunct parts are joined when enough data is available. Should be called directly at the beginning of getCommand()

printMap

public void printMap()
Debug code: Prints an ASCII version of the map to the terminal

getPathError

public int getPathError()
If any of the methods dealing with shortest paths fails, this method can be used to obtain an error code explaing the reason of the failure. If a method does work successfully, this method should not be called, as it may return any result in this case.

addAdjacentItemsToQueue

private int addAdjacentItemsToQueue(MapItem mapItem,
                                    int predecessorDirection,
                                    MapItemMatcher mapItemMatcher,
                                    java.util.TreeSet queue,
                                    int addedToQueue)
Adds add items linked to the given mapItem to the priority queue of the dijstra algorithm. Takes care that the correct weights are chosen for the links. Called by performDij().
Parameters:
mapItem - the MapItems linked to this MapItem will be added to the queue.
predecessorDirection - the direction the predecessor of the specified MapItem is linked with the specified MapItem. That is, the direction the robot has when it sits on mapItem. This value is used for calculating the weight of the links: The link to the item the robot looks at gets the weight 1 (for one MoveAction), all others get the weight 2 (for one RotateAction and one MoveAction).
mapItemMatcher - the mapItemMatcher used for this search.
queue - the priority queue used by this search. The adjacent items will be added to this queue.
addedToQueue - this value is increased whenever a MapItem has been added to the queue in order to give the queue a total ordering. The new value of addedToQueue will be returned by this method.
Returns:
the new value of addedToQueue

performDij

private java.util.LinkedList performDij(MapItemMatcher mapItemMatcher,
                                        MapItem startMapItem,
                                        int maxDistance,
                                        int flags)
Searches for the nearest map item that matches with the specified search criteria. This is done with the Dijkstra algorithm on the map item graph. Edges on which the robot has not to change its direction, are weighted 1 and edges on which the robot has to rotate, are weighted with 2. Thus, this function finds the shortest way in terms of actions, is however somewhat slower than the breadth first search.
Parameters:
mapItemMatcher - instance of an implementation of a MapItemMatcher. Used to determine what map items are actually wanted.
startMapItem - the map item the search starts at
maxDistance - if the search exceeds this distance without being successful, the search will be stopped
Returns:
LinkedList of MapItems representing the shortest way to the item that has been searched for. The given startMapItem is included as the first map item in this list. If the specified MapItemMatcher searched for more than one map item, this is the path to the map item for which mapItemMatcher.finish() returned true. To get the other paths you have to use MapItem.getBfsPredecessor().

findShortestPath

public Map.ShortestPath findShortestPath(MapItemMatcher mapItemMatcher,
                                         int maxDistance,
                                         int flags)
Tries to find a shortest path that is at most maxDistance steps long to a map item that can be specified using the mapItemMatcher.
Parameters:
mapItemMatcher - instance of an implementation of a MapItemMatcher. Used to determine what map items are actually wanted.
maxDistance - paths that are returned by this method will not exceed this distance.
Returns:
A ShortestPath to the requested map item, or null if there was an error. Use getPathError() to find out what error.

unknownFields

public Map.ShortestPath unknownFields()
Checks whether there are still unknown fields in the arena. The result is returned as a ShortestPath to something. To find out, to what the ShortestPath leads, use getPathError(). These are the possible results:

preTeleportUsage

public boolean preTeleportUsage()
This method tells the map that the robot is about to use a teleport. It must be called when the strategies want to use a teleporter manually, i.e. not by using the AbractActions generated by nextStep() (nextStep() calls this method already internally).

postTeleportUsage

public AbstractAction postTeleportUsage()
This method tells the map that the robot has just passed a teleport. It must be called when the strategies want to use a teleporter manually, i.e. not by using the AbractActions generated by nextStep() (nextStep() calls this method already internally). It may return an AbstractAction != null. If so, the robot should pass this action to the getCommand() method and call in the next gameRound postTeleportUsage() again until it returns null.
Returns:
AbstractAction action needed for orientation of the robot.

teleportHasBeenUsed

public boolean teleportHasBeenUsed()
Determines using map internal data whether the robot has used a teleporter in the previous round. This method should only be used to calculate path weights and not for determining actions. This is done by postTeleportUsage()
Returns:
true if the robot walked through a teleport in the previous round

preUnknownReactableUsage

public void preUnknownReactableUsage()
Records the energy and the portable-size of the robot when the robot is about to use an unknown reactable. Obviously, this method should be called always before the robot tries the effect of an unknown reactable. Using the ShortestPath class, this method is called automatically.

isBadReactableClass

public boolean isBadReactableClass(java.lang.Class itemClass)
Checks using "empiric data" stored in badReactableClasses whether this reactable class is known to cause harm to a robot
Parameters:
itemClass - The Class object of an unknown reactable
Returns:
true if the reactable is known to cause harm.

postUnknownReactableUsage

public void postUnknownReactableUsage()
Checks whether the reactable that was just used by the robot has caused any damage. If so, the class of the reactable is marked as "bad" and all other already recorded unknown reactables are checked whether they belong to this class. This method is called by trackPosition() and there should be no need to call this method from another place.

setWhenCheck

public void setWhenCheck(int whenCheck)
Write access method for attribute whenCheck
Parameters:
whenCheck - the new value for whenCheck

isWellGettingFar

public boolean isWellGettingFar()
isWellGettingFar() tells the robot in a fast way, whether the next well is dangerously too far away. Must be called in each round of game!
Returns:
true, when Robot should start EnergyStrategy(), or false, when either no well was found yet or everything is OK.