All Packages Class Hierarchy This Package Previous Next Index
Class gpsys.cos.Robot
java.lang.Object
|
+----gpsys.cos.Robot
- public class Robot
- extends Object
- implements Serializable
The terrain robot itself is a robot that moves around on a terrain, bumping in the lamps.
Unfortunately it only has a limited number of energy units available.
These are divided into a number of movements.
The terrainrobot therefore stops when these units have run
out. Lamps increase their energy at each turn, lose it when the robot bump in.
The robot can gain "released" energy from the lamp for itself by going on the
Charging Station
- Author:
- Emmanuel PIERRE
DEA IARFA,
-
direction
- The current direction of the robot, can be one of NORTH, EAST, SOUTH or
WEST.
-
EAST
- The value of direction when the robot is pointing EAST.
-
movementAvailable
- The ration of movement operations available.
-
NORTH
- The value of direction when the robot is pointing NORTH.
-
ROBOT_SAFE
- The energy meaning the robot is safe (for IFDIE op)
-
SOUTH
- The value of direction when the robot is pointing SOUTH.
-
terrain
- The terrain to be moveed.
-
WEST
- The value of direction when the robot is pointing WEST.
-
x
- The X corrdinate of the robot on the terrain.
-
y
- The Y corrdinate of the robot on the terrain.
-
Robot(Terrain)
- Construct a new robot to terrain the specified terrain.
-
back()
- Movement energy permitting, moves the robot back by one square in the
current direction.
-
forward()
- Movement energy permitting, moves the robot forward by one square in the
current direction.
-
halt()
- Movement energy permitting, moves the robot back by one square in the
current direction.
-
ifacs()
- At the charging station.
-
ifal()
- Lamp detection.
-
ifcharged()
- At the charging station and full.
-
ifcsa()
- Charging station ahead.
-
ifdie()
- If dying.
-
iflgr()
- Lamp Greater on Left than Right.
-
ifoba()
- Obstacle detection.
-
ifsysunsafe()
- System Unsafe !
-
left()
- Movement energy permitting, moves the robot forward by one square in the
current direction cutting the grass on that square.
-
reset()
- Resets the robot state to default values (position = (3,5),
direction = SOUTH, movementAvailable = 20*4.
-
right()
- Movement energy permitting, moves the robot forward by one square in the
current direction cutting the grass on that square.
terrain
Terrain terrain
- The terrain to be moveed.
x
int x
- The X corrdinate of the robot on the terrain.
y
int y
- The Y corrdinate of the robot on the terrain.
direction
int direction
- The current direction of the robot, can be one of NORTH, EAST, SOUTH or
WEST.
movementAvailable
int movementAvailable
- The ration of movement operations available.
NORTH
public static final int NORTH
- The value of direction when the robot is pointing NORTH.
EAST
public static final int EAST
- The value of direction when the robot is pointing EAST.
SOUTH
public static final int SOUTH
- The value of direction when the robot is pointing SOUTH.
WEST
public static final int WEST
- The value of direction when the robot is pointing WEST.
ROBOT_SAFE
public static final int ROBOT_SAFE
- The energy meaning the robot is safe (for IFDIE op)
Robot
public Robot(Terrain terrain)
- Construct a new robot to terrain the specified terrain. The robot starts at
the default position and direction. The number of movement operations available
are both initialised to 80.
- Parameters:
- terrain - The terrain.
reset
public void reset()
- Resets the robot state to default values (position = (3,5),
direction = SOUTH, movementAvailable = 20*4.
ifacs
public final boolean ifacs()
- At the charging station.
ifcsa
public final boolean ifcsa()
- Charging station ahead.
iflgr
public final boolean iflgr()
- Lamp Greater on Left than Right.
ifcharged
public final boolean ifcharged()
- At the charging station and full.
ifdie
public final boolean ifdie()
- If dying.
ifsysunsafe
public final boolean ifsysunsafe()
- System Unsafe !
right
public final void right()
- Movement energy permitting, moves the robot forward by one square in the
current direction cutting the grass on that square.
left
public final void left()
- Movement energy permitting, moves the robot forward by one square in the
current direction cutting the grass on that square.
forward
public final void forward()
- Movement energy permitting, moves the robot forward by one square in the
current direction.
ifoba
public final boolean ifoba()
- Obstacle detection.
ifal
public final boolean ifal()
- Lamp detection.
back
public final void back()
- Movement energy permitting, moves the robot back by one square in the
current direction.
halt
public final void halt()
- Movement energy permitting, moves the robot back by one square in the
current direction.
All Packages Class Hierarchy This Package Previous Next Index