giavamachia
Class Robot

java.lang.Object
  |
  +--giavamachia.MobileObject
        |
        +--giavamachia.Robot
All Implemented Interfaces:
java.lang.Runnable

public abstract class Robot
extends giavamachia.MobileObject
implements java.lang.Runnable

Each playable Robot must subclass this class and implement method run().

See Also:
MobileObject, Runnable

Constructor Summary
  Robot()
          Creates a new Robot instance.
protected Robot(java.awt.Point p)
          Creates a new Robot instance.
 
Method Summary
 int actualDirection()
          The actual direction of the Robot.
 double actualDirectionInRad()
          The actual direction of the Robot.
 java.awt.Point actualPosition()
          The actual position of the Robot in the Arena
 int actualSpeed()
          The actual speed of the Robot.
protected  void fireBomb(int direction, int distance)
          If Robot is readyToFire(), it fires a bomb addressing a target far distance units in direction direction.
protected  void fireLaser()
          If Robot is readyToFire(), it fires a lasers addressing a target in direction actualDirection().
protected  void fireMissile(int direction)
          If Robot is readyToFire(), it fires a missile addressing a target in direction direction.
protected  int getStamina()
          It returns the vitality of the Robot.
protected  int getTemperature()
          It returns the temperature of the Robot.
protected  View look(int direction)
          Looks into direction searching for enemies and mines.
 java.lang.String name()
          The name of the Robot.
protected  void putMine(int time)
          If Robot is readyToFire() and time is greater than zero, it drops a mine that is going to explode time clock ticks later.
protected  boolean readyToFire()
           
protected  void run(int dir, int sp)
          Turn the Robot in direction dir and change its speed.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface java.lang.Runnable
run
 

Constructor Detail

Robot

protected Robot(java.awt.Point p)
Creates a new Robot instance.
Parameters:
p - Point of creation

Robot

public Robot()
Creates a new Robot instance.
Method Detail

name

public final java.lang.String name()
The name of the Robot.
Returns:
a String containing the name of the robot.

readyToFire

protected final boolean readyToFire()

look

protected final View look(int direction)
Looks into direction searching for enemies and mines. Scope is a slice of Consts.ROBOT_LOOK_SPREAD degrees of opening and Consts.ROBOT_LOOK_RANGE of radius. It returns the set of objects seen. FIXME: it returns only robots.
Parameters:
direction - degrees: starting at three o'clock, counter-clockwise.
Returns:
a set of Observations

putMine

protected final void putMine(int time)
If Robot is readyToFire() and time is greater than zero, it drops a mine that is going to explode time clock ticks later. It increase Robot temperature by Consts.MINE_POWER degrees.
Parameters:
time - clock ticks before explosion

fireBomb

protected final void fireBomb(int direction,
                              int distance)
If Robot is readyToFire(), it fires a bomb addressing a target far distance units in direction direction. It increases Robot temperature by Consts.BOMB_POWER degrees.
Parameters:
direction - degrees: starting at three o'clock, counter-clockwise. The method has no effect if direction is less than 0 or greater than 360.
distance - distance of the target

fireMissile

protected final void fireMissile(int direction)
If Robot is readyToFire(), it fires a missile addressing a target in direction direction. It increases Robot temperature by Consts.MISSILE_POWER degrees.
Parameters:
direction - degrees: starting at three o'clock, counter-clockwise. The method has no effect if direction is less than 0 or greater than 360.

fireLaser

protected final void fireLaser()
If Robot is readyToFire(), it fires a lasers addressing a target in direction actualDirection(). It increases Robot temperature by Consts.LASER_POWER degrees.

run

protected final void run(int dir,
                         int sp)
Turn the Robot in direction dir and change its speed.
Parameters:
dir - degrees: starting at three o'clock, counter-clockwise. The method has no effect if dir is less than 0 or greater than 360.
sp - new speed. The method pass control to the scheduler if sp is less than 0 or greater than Consts.ROBOT_MAX_SPEED.

getStamina

protected final int getStamina()
It returns the vitality of the Robot.
Returns:
a value of 0 means that the Robot is dead.

getTemperature

protected final int getTemperature()
It returns the temperature of the Robot.
Returns:
an int value between 0 and Robot.Consts.MAX_TEMP

actualPosition

public final java.awt.Point actualPosition()
The actual position of the Robot in the Arena
Returns:
a Point with coordinates of the Robot. The origin is the center of the Arena, x goes left to right, y goes bottom-up. Max x is Consts.DIMX/2, max y is Consts.DIMY/2

actualSpeed

public final int actualSpeed()
The actual speed of the Robot.
Returns:
the module of the speed.

actualDirection

public final int actualDirection()
The actual direction of the Robot.
Returns:
degrees: starting at three o'clock, counter-clockwise.

actualDirectionInRad

public final double actualDirectionInRad()
The actual direction of the Robot.
Returns:
radiants: starting at three o'clock, counter-clockwise.