de.uni_paderborn.robots.robot.group10
Class AbstractStrategy

java.lang.Object
  |
  +--de.uni_paderborn.robots.robot.group10.AbstractStrategy
Direct Known Subclasses:
CardStrategy, EnergyStrategy, ExitStrategy, MoveStrategy

public abstract class AbstractStrategy
extends java.lang.Object

AbstractStrategy


Field Summary
private static int cardDroppedDirection
          Stores the direction the robot's card was dropped by dropCard()
(package private)  CardFinder currentRobot
          attribute currentRobot for easy access
private static int EXCHANGED_CARD
          State for dropCard(): The robot has exchanged the card
private static int IDLE
          State for dropCard(): There is currently no card dropping process
private static int lastAction
          Stores the state dropCard() is in.
(package private)  Map map
          The map this strategy uses.
private static int MOVED_AWAY
          State for dropCard(): The robot has moved the card away that blocked the way
private static int PICKED_CARD
          State for dropCard(): The robot has picked up the card
private static int PICKED_OLD_CARD_AGAIN
          State for dropCard(): The robot picked again the card he dropped
private static CardData pickedCard
          Stores the card the robot picked up
protected  java.util.Random random
          random number generator
private  Map.ShortestPath shortestPath
          This field stores the shortestPath this strategy uses between the game rounds
private static int TURNED_BACK_TO_OLD
          State for dropCard(): The robot turned back to the card he dropped in the beginning
 
Constructor Summary
AbstractStrategy(CardFinder robot)
          constructor method
 
Method Summary
 AbstractRobotAction dropCard(CardData cardToDrop, boolean moveCardAway)
          This method generates AbstractActions in order to pickup a card that lies in front of the robot when the robot's portable is already full.
private  AbstractRobotAction findFreeField()
          Tries to create a RotateAction in order to rotate to an possibly empty field.
abstract  AbstractRobotAction getCommand()
          get command for next action (abtract)
 CardFinder getCurrentRobot()
          read access for currentRobot
 Map getMap()
          read access for the map
 void setCurrentRobot(CardFinder value)
          write access for cf
 void setMap(Map value)
          write access for the map
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

random

protected java.util.Random random
random number generator

map

Map map
The map this strategy uses. For easy access.

currentRobot

CardFinder currentRobot
attribute currentRobot for easy access

IDLE

private static final int IDLE
State for dropCard(): There is currently no card dropping process

EXCHANGED_CARD

private static final int EXCHANGED_CARD
State for dropCard(): The robot has exchanged the card

PICKED_CARD

private static final int PICKED_CARD
State for dropCard(): The robot has picked up the card

MOVED_AWAY

private static final int MOVED_AWAY
State for dropCard(): The robot has moved the card away that blocked the way

TURNED_BACK_TO_OLD

private static final int TURNED_BACK_TO_OLD
State for dropCard(): The robot turned back to the card he dropped in the beginning

PICKED_OLD_CARD_AGAIN

private static final int PICKED_OLD_CARD_AGAIN
State for dropCard(): The robot picked again the card he dropped

lastAction

private static int lastAction
Stores the state dropCard() is in.

cardDroppedDirection

private static int cardDroppedDirection
Stores the direction the robot's card was dropped by dropCard()

pickedCard

private static CardData pickedCard
Stores the card the robot picked up

shortestPath

private Map.ShortestPath shortestPath
This field stores the shortestPath this strategy uses between the game rounds
Constructor Detail

AbstractStrategy

public AbstractStrategy(CardFinder robot)
constructor method
Parameters:
robot - a reference to the CardFinder that uses the strategy
Method Detail

getCurrentRobot

public CardFinder getCurrentRobot()
read access for currentRobot
Returns:
currentRobot the current Robot

setCurrentRobot

public void setCurrentRobot(CardFinder value)
write access for cf
Parameters:
value - reference to the current CardFinder
Returns:
changed current CardFinder has changed

getMap

public Map getMap()
read access for the map
Returns:
Map the current Map

setMap

public void setMap(Map value)
write access for the map
Parameters:
value - the current Map

getCommand

public abstract AbstractRobotAction getCommand()
get command for next action (abtract)
Returns:
abstractAction the action to be performed

findFreeField

private AbstractRobotAction findFreeField()
Tries to create a RotateAction in order to rotate to an possibly empty field. Used by dropCard()
Returns:
A RotateAction to rotate to an empty field or null if no possibly empty field could be found

dropCard

public AbstractRobotAction dropCard(CardData cardToDrop,
                                    boolean moveCardAway)
This method generates AbstractActions in order to pickup a card that lies in front of the robot when the robot's portable is already full. Thus, the robot has to drop a card from his portable first. This card is specified by the cardToDrop parameter. The caller should call this method in each round until this method returns null. In this case, the drop procedure has finished. Note: There is no guarantee, that the robot stands in the original direction when the procedure is finished.
Parameters:
cardToDrop - a card from the robot's portable that is dropped
maveCardAway - is true if a card needs to be moved away