world
Class Robot

java.lang.Object
  |
  +--world.Robot
All Implemented Interfaces:
Comparable, ID, Locality
Direct Known Subclasses:
OpponentRobot, PlayerRobot

public abstract class Robot
extends Object
implements ID, Locality

Class that implements robots for the ICFP-2002 programming contest entry.

Version:
$Revision: 1.7 $
Author:
Allen D. Ball

Constructor Summary
protected Robot(World world, int id, int capacity)
          Creates a robot.
 
Method Summary
 int compareTo(Object object)
          Compares this object with the specified object for order.
 void drop(int id)
          Method to drop a package.
 int getCapacity()
          Method to get the robot's capacity.
 int getId()
          Method to get the robot ID.
 int getLoad()
          Method to get the robot's current load.
 Sack getSack()
          Method to get the tile's sack.
 int getScore()
          Method to get the robot score.
 Tile getTile()
          Method to get the robot's [location] tile.
 Tile[] getTrail()
           
 List getTrailList()
           
 World getWorld()
          Method to get the robot's world of residence.
 boolean isVulnerable()
          Method to determine if the robot is vulnerable.
 void moveEast()
          Method to move the robot East.
 void moveNorth()
          Method to move the robot North.
 void moveSouth()
          Method to move the robot South.
 void moveWest()
          Method to move the robot West.
 void pick(int id)
          Method to pick[-up] a package.
protected  void setCapacity(int capacity)
          Method to set the robot's capacity.
 void setScore(int score)
          Method to set the robot score.
 void setTile(Tile tile)
          Method to set the robot's [location] tile.
 String toString()
          Method to get a string description of the robot.
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Robot

protected Robot(World world,
                int id,
                int capacity)
Creates a robot.
Parameters:
world - The world this robot resides in.
id - The robot ID.
capacity - The robot's capacity.
Method Detail

getWorld

public World getWorld()
Method to get the robot's world of residence.
Returns:
The robot's world.

getId

public int getId()
Method to get the robot ID.
Specified by:
getId in interface ID
Returns:
The robot ID.

getCapacity

public int getCapacity()
Method to get the robot's capacity.
Returns:
The robot's capacity.

setCapacity

protected void setCapacity(int capacity)
Method to set the robot's capacity.
Parameters:
capacity - The robot's capacity.

getLoad

public int getLoad()
Method to get the robot's current load.
Returns:
The robot's load.

getScore

public int getScore()
Method to get the robot score.
Returns:
The robot score.

setScore

public void setScore(int score)
Method to set the robot score.
Parameters:
score - The robot score.

getSack

public Sack getSack()
Method to get the tile's sack.
Returns:
The tile's sack.

getTile

public Tile getTile()
Method to get the robot's [location] tile.
Specified by:
getTile in interface Locality
Returns:
The robot's [location] tile.

setTile

public void setTile(Tile tile)
Method to set the robot's [location] tile.
Returns:
The robot's [location] tile.

moveNorth

public void moveNorth()
Method to move the robot North.

moveSouth

public void moveSouth()
Method to move the robot South.

moveEast

public void moveEast()
Method to move the robot East.

moveWest

public void moveWest()
Method to move the robot West.

getTrailList

public List getTrailList()

getTrail

public Tile[] getTrail()

drop

public void drop(int id)
Method to drop a package.
Parameters:
id - The package ID of the package to be dropped.

pick

public void pick(int id)
Method to pick[-up] a package.
Parameters:
id - The package ID of the package to be picked.

isVulnerable

public boolean isVulnerable()
Method to determine if the robot is vulnerable.
Returns:
True if a another robot occupies a neighboring space; false otherwise.

toString

public String toString()
Method to get a string description of the robot.
Overrides:
toString in class Object
Returns:
The string describing the robot.

compareTo

public int compareTo(Object object)
Compares this object with the specified object for order. Returns a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object.
Specified by:
compareTo in interface Comparable
Parameters:
object - The object to be compared.
See Also:
Comparable


Copyright 2002 Allen D. Ball. All rights reserved.