examples.dlife.models.simpleworld
Class RandomController

java.lang.Object
  extended by dlife.robot.Controller
      extended by dlife.models.simpleworld.SimpleWorldRobotController
          extended by 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:

  1. Launch the dlife.robot.gui.controlcenter
  2. Select dlife.models.simpleworld.SimpleWorldRobot in the "Robot:" drop down list.
  3. Click the button next to the "Controller:" label.
  4. Navigate to the dLifeDist/examples/dlife/models/simpleworld/ directory.
  5. Choose the RandomController.class file.
  6. Click the "Start Up" button.
  7. Click "Create" in the dialog that appears.
  8. Click the "World" tab in the ControlCenter to display the SimpleWorld GUI.
  9. Click "Run"

The source code for this class is contained in the file:

Version:
Oct 5, 2010
Author:
Grant Braught, Dickinson College

Field Summary
 
Fields inherited from class dlife.models.simpleworld.SimpleWorldRobotController
GUI_DELAY, NO_GUI_DELAY
 
Constructor Summary
RandomController()
           
 
Method Summary
 void step(SimpleWorldRobot robot)
          Invoked once for each control opportunity provided to the robot.
 
Methods inherited from class dlife.models.simpleworld.SimpleWorldRobotController
startUp, startUp, step
 
Methods inherited from class dlife.robot.Controller
shutDown
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RandomController

public RandomController()
Method Detail

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.