de.uni_paderborn.robots.data
Class Robot

java.lang.Object
  |
  +--de.uni_paderborn.robots.data.Item
        |
        +--de.uni_paderborn.robots.data.Robot
All Implemented Interfaces:
Identifyable, java.io.Serializable

public class Robot
extends Item

A robot in the arena.

See Also:
Serialized Form

Field Summary
private  java.util.HashSet cards
          cards of the robot
private  int direction
          direction of robot, 0 if looking in south direction, larger numbers are reached by turning right
private  boolean disqualified
          true, if robot is disqualified
private  int energy
          energy of the robot
static int FORWARD
          FORWARD direction (do not change the value!)
private  boolean hasExitEntered
          true if robot has entered the Exit
private  RobotFunctions intelligence
          brain of robot, interface to thread class with implemented strategy
static int LEFT
          LEFT direction (do not change the value!)
private static int maxEnergy
          maximum of energy a robot can have
private  java.lang.String name
          the name of the robot
private  RobotFunctions proxy
          proxy which procotols communication between arena and robot
static int RIGHT
          RIGHT direction (do not change the value!)
static long serialVersionUID
          used for serialization
private  int type
          type of robot, used for identifying robots by the game and gui classes
 
Fields inherited from class de.uni_paderborn.robots.data.Item
field, id
 
Constructor Summary
Robot(RobotFunctions proxy, RobotFunctions intelligence, java.lang.String name, int type, int direction, int energy)
          constructor, creates a robot with the specified brain, direction and energy.
 
Method Summary
 boolean addCard(Card card)
          Add a card to robots portable.
 boolean changeEnergy(int delta)
          Changes the robots energy by adding delta.
 void disqualify()
          Disqualifies robot.
 boolean equals(Robot robot)
          Tests if an object is equal to this one.
 java.util.HashSet getCards()
          Returns a hashset of the card in the robots portable.
 int getDirection()
          Returns direction of robot.
 int getEnergy()
          Returns the energy of the robot.
 boolean getExitEnteredFlag()
          Returns true if robot has entered the exit
 Field getFieldInDirection(int bearing)
          Returns field in direction
 RobotFunctions getIntelligence()
          Returns the RobotFunctions interface of this robot.
static int getMaxEnergy()
          Returns the maximum energy a robot can have.
 java.lang.String getName()
          Returns the name of the robot; the name is equal to the class name.
 int getPoints()
          Returns the points of this robot.
 RobotFunctions getProxy()
          Returns the proxy interface for this robot.
 int getType()
          Returns the type of the robot.
 boolean isDisqualified()
          Determines if robot is disqualified.
 boolean isSleeping()
          Determines if robot is sleeping that means its energy is equal to 0.
 int numberOfCards()
          Returns the number of cards owned by the robot.
 boolean removeCard(Card card)
          Removes a card from a robots portable
 void setDirection(int direction)
          Sets direction of robot.
 boolean setEnergy(int energy)
          Sets energy of the robot.
 void setExitEnteredFlag()
          Sets hasExitEntered to true
static boolean setMaxEnergy(int newMaxEnergy)
          Sets the maximum of energy a robot can have.
 void setType(int type)
          Sets the type of the robot.
 
Methods inherited from class de.uni_paderborn.robots.data.Item
finalize, getField, getID, getItemName, setField
 
Methods inherited from class java.lang.Object
, clone, equals, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

serialVersionUID

public static final long serialVersionUID
used for serialization

LEFT

public static final int LEFT
LEFT direction (do not change the value!)

FORWARD

public static final int FORWARD
FORWARD direction (do not change the value!)

RIGHT

public static final int RIGHT
RIGHT direction (do not change the value!)

type

private int type
type of robot, used for identifying robots by the game and gui classes

disqualified

private boolean disqualified
true, if robot is disqualified

hasExitEntered

private boolean hasExitEntered
true if robot has entered the Exit

direction

private int direction
direction of robot, 0 if looking in south direction, larger numbers are reached by turning right

energy

private int energy
energy of the robot

maxEnergy

private static int maxEnergy
maximum of energy a robot can have

cards

private java.util.HashSet cards
cards of the robot

intelligence

private RobotFunctions intelligence
brain of robot, interface to thread class with implemented strategy

proxy

private RobotFunctions proxy
proxy which procotols communication between arena and robot

name

private java.lang.String name
the name of the robot
Constructor Detail

Robot

public Robot(RobotFunctions proxy,
             RobotFunctions intelligence,
             java.lang.String name,
             int type,
             int direction,
             int energy)
constructor, creates a robot with the specified brain, direction and energy.
Parameters:
proxy - proxy which protocols communication between arena and robot
intelligence - interface to robot thread class with implemented strategy
name - the name for the robot
type - type of robot, used for identifying robots by the game and gui classes
direction - direction of robot
energy - initial energy of robot
Method Detail

getDirection

public int getDirection()
Returns direction of robot.
Returns:
direction of robot

setDirection

public void setDirection(int direction)
Sets direction of robot.
Parameters:
direction - new direction of robot

setMaxEnergy

public static boolean setMaxEnergy(int newMaxEnergy)
Sets the maximum of energy a robot can have.
Parameters:
newMaxEnergy - new maximum energy of robots
Returns:
true, if maximum energy was set successfully, false, if not

getMaxEnergy

public static int getMaxEnergy()
Returns the maximum energy a robot can have.
Returns:
maximum energy of robots

addCard

public boolean addCard(Card card)
Add a card to robots portable.
Parameters:
card - card to add to the robots portable
Returns:
true, if operation was successful, false if not

removeCard

public boolean removeCard(Card card)
Removes a card from a robots portable
Parameters:
card - card to remove from the robots portable
Returns:
true, if operation was successful, false if not

getCards

public java.util.HashSet getCards()
Returns a hashset of the card in the robots portable.
Returns:
hashset of the cards in the robots portable

numberOfCards

public int numberOfCards()
Returns the number of cards owned by the robot.

getEnergy

public int getEnergy()
Returns the energy of the robot.
Returns:
energy of robot

setEnergy

public boolean setEnergy(int energy)
Sets energy of the robot.
Parameters:
energy - of robot
Returns:
true, if 0 <= energy <= maxEnergy, false, if not

changeEnergy

public boolean changeEnergy(int delta)
Changes the robots energy by adding delta.
Parameters:
delta - add to the robots current energy.
Returns:
true, if 0 <= energy+delta <= maxEnergy

isSleeping

public boolean isSleeping()
Determines if robot is sleeping that means its energy is equal to 0.
Returns:
true, if robot is sleeping, false, if not

isDisqualified

public boolean isDisqualified()
Determines if robot is disqualified.
Returns:
true, if robot is disqualified, false, if not

disqualify

public void disqualify()
Disqualifies robot.

setType

public void setType(int type)
Sets the type of the robot.
Parameters:
type - of robot

getType

public int getType()
Returns the type of the robot.
Returns:
type of robot

getIntelligence

public RobotFunctions getIntelligence()
Returns the RobotFunctions interface of this robot.
Returns:
interface to robot thread class with implemented strategy

getProxy

public RobotFunctions getProxy()
Returns the proxy interface for this robot.
Returns:
proxy interface for this robot

getName

public java.lang.String getName()
Returns the name of the robot; the name is equal to the class name.
Returns:
the name of the robot

equals

public boolean equals(Robot robot)
Tests if an object is equal to this one.
Returns:
true, if the two objects are equal, false if not

getPoints

public int getPoints()
Returns the points of this robot.
Returns:
points of this robot

getFieldInDirection

public Field getFieldInDirection(int bearing)
Returns field in direction
Returns:
a Field object if a valid direction (LEFT, FORWARD, RIGHT) is specified, null if not

setExitEnteredFlag

public void setExitEnteredFlag()
Sets hasExitEntered to true

getExitEnteredFlag

public boolean getExitEnteredFlag()
Returns true if robot has entered the exit
Returns:
true, robot has entered exit, false if not