examples.dlife.models.simpleworld
Class RandomController
java.lang.Object
dlife.robot.Controller
dlife.models.simpleworld.SimpleWorldRobotController
examples.dlife.models.simpleworld.RandomController
public class RandomController
- extends SimpleWorldRobotController
Move the SimpleWorldRobot randomly. This controller moves forward, rotates left
or rotates right at random.
To run this example:
- Launch the
dlife.robot.gui.controlcenter
- Select
dlife.models.simpleworld.SimpleWorldRobot in the "Robot:" drop down
list.
- Click the button next to the "Controller:" label.
- Navigate to the
dLifeDist/examples/dlife/models/simpleworld/
directory.
- Choose the
RandomController.class file.
- Click the "Start Up" button.
- Click "Create" in the dialog that appears.
- Click the "World" tab in the ControlCenter to display the SimpleWorld GUI.
- Click "Run"
The source code for this class is contained in the file:
- Version:
- Oct 5, 2010
- Author:
- Grant Braught, Dickinson College
|
Method Summary |
void |
step(SimpleWorldRobot robot)
Invoked once for each control opportunity provided to the robot. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
RandomController
public RandomController()
step
public void step(SimpleWorldRobot robot)
- Description copied from class:
dlife.models.simpleworld.SimpleWorldRobotController
- Invoked once for each control opportunity provided to the robot. This
method may invoke any of the methods in the
SimpleWorldRobot class to read sensors
or move the robot. The robot's life force is decreased by one unit each
time step is called. In addition, each movement of the robot caused by
the code in step costs one unit of life force (e.g. rotating right and
then moving forward costs 2 units).
- Specified by:
step in class SimpleWorldRobotController
- Parameters:
robot - The robot being controlled.