de.uni_paderborn.robots.robot.group10
Class CardFinder

java.lang.Object
  |
  +--de.uni_paderborn.robots.robot.group10.CardFinder
All Implemented Interfaces:
RobotFunctions

public class CardFinder
extends java.lang.Object
implements RobotFunctions


Field Summary
(package private)  AbstractStrategy cardStrat
          the different strategies
(package private)  boolean cardStratActive
          variable which is set if the card-strategy is active
(package private)  RobotData currentRobotData
          reference to the current data of the robot
(package private)  int direction
          value of the current direction of the robot
private  int energyLastRound
          temp variable for energy from last round
(package private)  AbstractStrategy energyStrat
          the different strategies
(package private)  boolean energyStratActive
          variable which is set if the energy-strategy is active
(package private)  int exceptionCnt
          counter for the exceptions in a row
(package private)  boolean exitKnown
          variable which is set if the exit is known
(package private)  AbstractStrategy exitStrat
          the different strategies
(package private)  boolean exitStratActive
          variable which is set if the exit-strategy is active
(package private)  Map map
          reference to the map of the robot
(package private)  boolean mapFound
          attribute if the right one of the three maps already have been found
(package private)  Map mapLeft
          reference to the map of the robot
(package private)  Map mapRight
          reference to the map of the robot
(package private) static int MAX_EXCEPTIONS
          maximum number of exceptions in a row before an exception handling is forced
(package private) static int MAX_NOACTIONS
          maximum number of noactions in a row before an exception handling is forced
private  int maxEnergy
          memorizes maxEnergy
(package private)  AbstractStrategy moveStrat
          the different strategies
(package private)  int noActionCnt
          counter for the noActions in a row
protected  java.util.Random random
          random number generator
(package private)  AbstractStrategy stupidStrat
          the different strategies
private  int tmpEnergy
          memorizes maxEnergy
private  int turnNo
          turn counter
(package private)  boolean wholeArenaKnown
          variable which is set if the whole arena is known
 
Constructor Summary
CardFinder()
          constructor
 
Method Summary
 CardData calcNewCardValue(CardData newCard)
          If the robot has to put down a card this function supplies the card to put down.
 boolean cardsInFront()
          This method returns if the robots is seeing any card in front, left or right
static void debugPrintln(java.lang.String s)
          Method which is used for diagnostic output
 boolean exchangeOk(CardData myCard, CardData otherCard)
          Robot accepts cards exchange, if new cards would be better.
 CardData exchangeProposal(CardData[] cards)
          Returns an random card, if the robot has at least one card.
 boolean getCardStratActive()
          Method for getting the status of the card strategy
 AbstractRobotAction getCommand(RobotData robotData)
          Returns the next command.
 int getDirection()
          Method to access the direction
 int getEnergy()
          This method returns the current Energy of the robot
 int getEnergyLastRound()
          This method returns the value of the energy in the last round
 boolean getEnergyStratActive()
          Method for getting the status of the energy strategy
 boolean getExitStratActive()
          Method for getting the status of the exit strategy
 CardData[] getHand()
          This method returns the hand from currentRobotData
 int getIdOfCurrentField()
          This method returns the id of the field where the robot is currently
 int getIdOfFieldInFront()
          This method returns the id of the fieldID in front of the robot
 int getIdOfFieldLeft()
          This method returns the id of the fieldID left of the robot
 int getIdOfFieldRight()
          This method returns the id of the fieldID right of the robot
 ItemData getItemInFrontOfRobot()
          This method returns a reference to the item in front of the robot
 ItemData getItemLeftOfRobot()
          This method returns a reference to the item left of the robot
 ItemData getItemRightOfRobot()
          This method returns a reference to the item right of the robot
 Map getMap()
          Method which returns a reference to the current map
 int getMaxEnergy()
          Method which return the maximum of energy a robot can have
 AbstractStrategy getMoveStrat()
          This method returns a reference to the move strategy of the robot
 void initCardFinder()
          method to initialize the cardfinder
 boolean isExitKnown()
          access method whether the exit is known or not
 boolean isWholeArenaKnown()
          access method whether whole arena is known or not
 void setCardStratActive(boolean value)
          Method for setting the status of the card strategy
 void setDirection(int value)
          Method to set the direction
 void setEnergyLastRound(int value)
          Method to set the energy to compare it in the next round
 void setEnergyStratActive(boolean value)
          Method for setting the status of the energy strategy
 void setExitKnown()
          method which is called when the exit is found
 void setExitStratActive(boolean value)
          Method for setting the status of the exit strategy
 void setMap(Map value)
          This method returns a reference to the map of the robot
 void setMaxEnergy(int value)
          Method which sets the maximum of energy a robot can have
 void setWholeArenaKnown(boolean value)
          Method for setting the status if the whole arena is known
 int sizeOfPortable()
          This method returns the number of cards the robot has
 
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

exceptionCnt

int exceptionCnt
counter for the exceptions in a row

MAX_EXCEPTIONS

static int MAX_EXCEPTIONS
maximum number of exceptions in a row before an exception handling is forced

noActionCnt

int noActionCnt
counter for the noActions in a row

MAX_NOACTIONS

static int MAX_NOACTIONS
maximum number of noactions in a row before an exception handling is forced

currentRobotData

RobotData currentRobotData
reference to the current data of the robot

map

Map map
reference to the map of the robot

mapLeft

Map mapLeft
reference to the map of the robot

mapRight

Map mapRight
reference to the map of the robot

mapFound

boolean mapFound
attribute if the right one of the three maps already have been found

direction

int direction
value of the current direction of the robot

maxEnergy

private int maxEnergy
memorizes maxEnergy

tmpEnergy

private int tmpEnergy
memorizes maxEnergy

turnNo

private int turnNo
turn counter

energyLastRound

private int energyLastRound
temp variable for energy from last round

moveStrat

AbstractStrategy moveStrat
the different strategies

energyStrat

AbstractStrategy energyStrat
the different strategies

stupidStrat

AbstractStrategy stupidStrat
the different strategies

exitStrat

AbstractStrategy exitStrat
the different strategies

cardStrat

AbstractStrategy cardStrat
the different strategies

energyStratActive

boolean energyStratActive
variable which is set if the energy-strategy is active

exitStratActive

boolean exitStratActive
variable which is set if the exit-strategy is active

cardStratActive

boolean cardStratActive
variable which is set if the card-strategy is active

wholeArenaKnown

boolean wholeArenaKnown
variable which is set if the whole arena is known

exitKnown

boolean exitKnown
variable which is set if the exit is known
Constructor Detail

CardFinder

public CardFinder()
constructor
Method Detail

initCardFinder

public void initCardFinder()
method to initialize the cardfinder

getCommand

public AbstractRobotAction getCommand(RobotData robotData)
Returns the next command. It is ensured that the robot does not runs against any item! The method also catches all exceptions and forces special exception handling routines.
Specified by:
getCommand in interface RobotFunctions
Parameters:
robotData - a reference to the data of the robot
Returns:
reference to the AbstractRobotAction-Object which should be performed

exchangeProposal

public CardData exchangeProposal(CardData[] cards)
Returns an random card, if the robot has at least one card.
Specified by:
exchangeProposal in interface RobotFunctions
Parameters:
cards - a reference to the cards of the robot
Returns:
reference to the card which the robot offers

exchangeOk

public boolean exchangeOk(CardData myCard,
                          CardData otherCard)
Robot accepts cards exchange, if new cards would be better.
Specified by:
exchangeOk in interface RobotFunctions
Following copied from interface: de.uni_paderborn.robots.robotArenaInterface.RobotFunctions
Parameters:
myCard - card the robot wants to give away
otherCard - card the robot wants to have
Returns:
true if the robot is willing to change

debugPrintln

public static void debugPrintln(java.lang.String s)
Method which is used for diagnostic output
Parameters:
s - the string which should be prompted

getEnergyStratActive

public boolean getEnergyStratActive()
Method for getting the status of the energy strategy

setEnergyStratActive

public void setEnergyStratActive(boolean value)
Method for setting the status of the energy strategy
Parameters:
value, - true if the strategy should be set active

getExitStratActive

public boolean getExitStratActive()
Method for getting the status of the exit strategy

setExitStratActive

public void setExitStratActive(boolean value)
Method for setting the status of the exit strategy
Parameters:
value, - true if the strategy should be set active

getCardStratActive

public boolean getCardStratActive()
Method for getting the status of the card strategy

setCardStratActive

public void setCardStratActive(boolean value)
Method for setting the status of the card strategy
Parameters:
value, - true if the strategy should be set active

isWholeArenaKnown

public boolean isWholeArenaKnown()
access method whether whole arena is known or not
Returns:
true if the whole arena is known

setWholeArenaKnown

public void setWholeArenaKnown(boolean value)
Method for setting the status if the whole arena is known
Parameters:
value, - true if the whole arena is known

isExitKnown

public boolean isExitKnown()
access method whether the exit is known or not
Returns:
true if exit is known

setExitKnown

public void setExitKnown()
method which is called when the exit is found

getDirection

public int getDirection()
Method to access the direction
Returns:
the int-value of the direction

setDirection

public void setDirection(int value)
Method to set the direction
Parameters:
value - the int-value of the direction

getEnergy

public int getEnergy()
This method returns the current Energy of the robot
Returns:
int-value of the energy

getEnergyLastRound

public int getEnergyLastRound()
This method returns the value of the energy in the last round
Returns:
int-value of the energy

setEnergyLastRound

public void setEnergyLastRound(int value)
Method to set the energy to compare it in the next round
Parameters:
value - the int-value of the energy

getMaxEnergy

public int getMaxEnergy()
Method which return the maximum of energy a robot can have
Returns:
int value of the energy

setMaxEnergy

public void setMaxEnergy(int value)
Method which sets the maximum of energy a robot can have
Parameters:
value - maximum of energy a robot can have

getHand

public CardData[] getHand()
This method returns the hand from currentRobotData
Returns:
the current hand array

getIdOfCurrentField

public int getIdOfCurrentField()
This method returns the id of the field where the robot is currently
Returns:
int-value of the current field

getIdOfFieldInFront

public int getIdOfFieldInFront()
This method returns the id of the fieldID in front of the robot
Returns:
int-value of the field in front of the robot

getItemInFrontOfRobot

public ItemData getItemInFrontOfRobot()
This method returns a reference to the item in front of the robot
Returns:
reference to the item in front of the robot

getIdOfFieldLeft

public int getIdOfFieldLeft()
This method returns the id of the fieldID left of the robot
Returns:
int-value of the field left of the robot

getItemLeftOfRobot

public ItemData getItemLeftOfRobot()
This method returns a reference to the item left of the robot
Returns:
reference to the item left of the robot

getIdOfFieldRight

public int getIdOfFieldRight()
This method returns the id of the fieldID right of the robot
Returns:
int-value of the field right of the robot

getItemRightOfRobot

public ItemData getItemRightOfRobot()
This method returns a reference to the item right of the robot
Returns:
reference to the item right of the robot

cardsInFront

public boolean cardsInFront()
This method returns if the robots is seeing any card in front, left or right
Returns:
whether there are cards in sight or not

setMap

public void setMap(Map value)
This method returns a reference to the map of the robot
Parameters:
reference - to the map of the robot

getMap

public Map getMap()
Method which returns a reference to the current map
Returns:
reference to the map of the robot

sizeOfPortable

public int sizeOfPortable()
This method returns the number of cards the robot has
Returns:
number of cards which the robot has

getMoveStrat

public AbstractStrategy getMoveStrat()
This method returns a reference to the move strategy of the robot
Returns:
reference to the move strategy

calcNewCardValue

public final CardData calcNewCardValue(CardData newCard)
If the robot has to put down a card this function supplies the card to put down. If the robot has less than five cards on the hand this function returns null, in that case the robot should pick up the card. If this function returns null and the robot has exactly five cards on the hand, he should not pick up the new card. If this function returns a card the robot should put down this card and pick up the new card If the argument is null, the method will decide which card brings the smallest loss when it has to be given away.
Parameters:
newCard - the card to evaluate with the current cardset.
Returns:
look into the description of this function