dLife Home Page

dlife.models.simpleworld
Class SimpleWorldRobotController

java.lang.Object
  extended by dlife.robot.Controller
      extended by dlife.models.simpleworld.SimpleWorldRobotController

public abstract class SimpleWorldRobotController
extends Controller

Abstract base class for controllers for SimpleWorldRobots. See the documentation for the dlife.models.simpleworld package for information about the use of this class.

Typically a concrete implementation of this class will contain only the step(SimpleWorldRobot robot) method. This method will accesses the robot's sensors using the following methods in the SimpleWorldRobot class:

Base on the sensors the step method will invoke the following methods to take actions in the world:

Several examples of SimpleWorldRobotControllers can be found in the examples.dlife.models.simpleworld package.

Version:
Sep 29, 2010
Author:
Grant Braught, Dickinson College
See Also:
SimpleWorld, SimpleWorldRobot, examples.dlife.models.simpleworld

Field Summary
static int GUI_DELAY
          Delay (in ms) used between calls to step when the GUI is displayed.
static int NO_GUI_DELAY
          Delay (in ms) used between calls to step when the GUI is not displayed.
 
Constructor Summary
SimpleWorldRobotController()
           
 
Method Summary
 void startUp()
          Invoked when this Controller is started in the ControlCenter.
 void startUp(Robot robot)
          Implementation of the startUp method required by Controller.
 void step()
          Implementation of the step method required by Controller.
abstract  void step(SimpleWorldRobot robot)
          Invoked once for each control opportunity provided to the robot.
 
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
 

Field Detail

GUI_DELAY

public static final int GUI_DELAY
Delay (in ms) used between calls to step when the GUI is displayed.

See Also:
Constant Field Values

NO_GUI_DELAY

public static final int NO_GUI_DELAY
Delay (in ms) used between calls to step when the GUI is not displayed.

See Also:
Constant Field Values
Constructor Detail

SimpleWorldRobotController

public SimpleWorldRobotController()
Method Detail

startUp

public final void startUp(Robot robot)
Implementation of the startUp method required by Controller. Stores an internal reference to the Robot being controlled so that it can be passed to the step method of the concrete implementations of this class.

Specified by:
startUp in class Controller
Parameters:
robot - the Robot that this Controller will be controlling.

step

public final void step()
Implementation of the step method required by Controller. This implementation ensures that the controller will not have a control opportunity if the robot's life force <= 0. It also decreases the life force by 1 unit for each control opportunity that is provided. In addition, this method introduces a small delay (100ms) if the controller is being run with a GUI. This slows down the animation to a speed that is reasonable to watch.

Specified by:
step in class Controller

startUp

public void startUp()
Invoked when this Controller is started in the ControlCenter. Sub-classes that wish to do initialization at startup (e.g. creating a neural network, etc...) should override this method.


step

public abstract void step(SimpleWorldRobot robot)
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).

Parameters:
robot - The robot being controlled.

dLife Home Page