|
dLife Home Page | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjava.util.Observable
dlife.robot.Robot
dlife.models.simpleworld.SimpleWorldRobot
public class SimpleWorldRobot
Robot for use in the SimpleWorld microworld. See the
documentation for the dlife.models.simpleworld package for
information about the use of this class. In addition, several examples of
SimpleWorldRobotControllers can be found in the
examples.dlife.models.simpleworld package.
SimpleWorld,
SimpleWorldRobotController,
examples.dlife.models.simpleworld| Constructor Summary | |
|---|---|
SimpleWorldRobot()
Construct a new SimpleWorldRobot with parameters provided by the user via a dialog box. |
|
SimpleWorldRobot(SimpleWorld theWorld,
int lifeForce)
Construct a new SimpleWorldRobot for the provided SimpleWorld. |
|
SimpleWorldRobot(SimpleWorld theWorld,
int lifeForce,
double smellErrorProb,
int smellRange,
double colorErrorProb,
int colorRange)
Construct a new SimpleWorldRobot for the provided SimpleWorld. |
|
| Method Summary | |
|---|---|
(package private) void |
decLifeForce(int amt)
Decrease the robot's life force. |
double |
getColorErrorProb()
Get the probability that this SimpleWorldRobot's color sensors will return an incorrect value. |
int |
getColorRange()
Get the range of the color sensors for this SimpleWorldRobot. |
int |
getFrontColor()
Get the value of the robot's front color sensor. |
int |
getLeftColor()
Get the value of the robot's left color sensor. |
int |
getLifeForce()
Get this SimpleWorldRobot's life force. |
int |
getRightColor()
Get the value of the robot's right color sensor. |
Device |
getSensor()
Get the sensor device that the robot uses to sense the world. |
int |
getSmell()
Get the value of the robot's smell sensor. |
double |
getSmellErrorProb()
Get the probability that this SimpleWorldRobot's smell sensor will return an incorrect value. |
int |
getSmellRange()
Get the range of the smell sensor for this SimpleWorldRobot. |
boolean |
hasLifeForce()
Check if this SimpleWorldRobot has any remaining life force. |
(package private) void |
incLifeForce(int amt)
Increase the robot's life force. |
void |
moveForward()
Move the robot forward one cell in the SimpleWorld. |
void |
resetLifeforce()
Reset this robot's life force to its initial value. |
void |
rotateLeft()
Rotate the robot to its left by 90 degrees in the SimpleWorld. |
void |
rotateRight()
Rotate the robot to its right by 90 degrees in the SimpleWorld. |
boolean |
runningWithGUI()
Check if this SimpleWorldRobot is running with a GUI or not. |
int |
runRobotNoGUI(SimpleWorldRobotController controller,
int steps)
Run the robot without displaying the GUI. |
int |
runRobotWithGUI(SimpleWorldRobotController controller,
int steps)
Run the robot with the GUI displayed. |
String |
sendMessage(String msg)
This method is unused by the SimpleWorldRobot. |
(package private) void |
setLifeForce(int value)
Set the robot's life force. |
void |
startUp()
Add sensors and effectors to this robot. |
| Methods inherited from class dlife.robot.Robot |
|---|
addDevice, freeze, getDevices, getRunTime, isAlive, removeDevice, setAlive, shutDown |
| Methods inherited from class java.util.Observable |
|---|
addObserver, clearChanged, countObservers, deleteObserver, deleteObservers, hasChanged, notifyObservers, notifyObservers, setChanged |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public SimpleWorldRobot()
public SimpleWorldRobot(SimpleWorld theWorld,
int lifeForce)
theWorld - the SimpleWorld that will be inhabited by the new robot.lifeForce - the amount of life force the robot begins with.
public SimpleWorldRobot(SimpleWorld theWorld,
int lifeForce,
double smellErrorProb,
int smellRange,
double colorErrorProb,
int colorRange)
theWorld - the SimpleWorld that will be inhabited by the new robot.lifeForce - the amount of life force the robot begins with.smellErrorProb - the probability of an error in the smell sensor
reading.smellRange - the range of the smell sensor.colorErrorProb - the probability of an error in the color sensor
reading.colorRange - the range of the color sensor.| Method Detail |
|---|
public void startUp()
startUp in class Robotpublic void resetLifeforce()
public Device getSensor()
public void moveForward()
public void rotateRight()
public void rotateLeft()
public boolean runningWithGUI()
public int getSmell()
SimpleWorld documentation for
information on the values that may be returned.
public int getLeftColor()
SimpleWorld documentation for
information on the values that may be returned.
public int getFrontColor()
SimpleWorld documentation for
information on the values that may be returned.
public int getRightColor()
SimpleWorld documentation for
information on the values that may be returned.
public final String sendMessage(String msg)
sendMessage in class Robotmsg - the message to be sent to the robot.
final void incLifeForce(int amt)
amt - the amount by which the life force should be increased.final void decLifeForce(int amt)
amt - the amount by which the life force should be decreased.final void setLifeForce(int value)
value - the new lifeforce.public int getLifeForce()
public boolean hasLifeForce()
public double getSmellErrorProb()
public double getColorErrorProb()
public int getSmellRange()
public int getColorRange()
public int runRobotNoGUI(SimpleWorldRobotController controller,
int steps)
If this robot's startUp method has not been invoked yet it will be invoked. The controller's startUp method will then be invoked to associate it with the robot. The controller's step method will then be invoked steps times or until the life force is depleted.
This method may be invoked multiple times on the same robot. When this is done it is equivalent to invoking the method once with the total number of steps. For example, the following calls:
mySWRobot.runRobotNoGUI(cont, 10); mySWRobot.runRobotNoGUI(cont, 10); mySWRobot.runRobotNoGUI(cont, 10);
is equivalent to the following single call:
mySWRobot.runRobotNoGUI(cont, 30);
controller - the SimpleWorldRobotController that is to be used to
control the robot.steps - the number of steps to run. Use -1 to run until lifeforce is
depleted.
Exception - if there is an exception starting the controller or
invoking step.
public int runRobotWithGUI(SimpleWorldRobotController controller,
int steps)
If this robot's startUp method has not been invoked yet it will be invoked. The GUI will then be displayed. The controller's startUp method will then be invoked to associate it with the robot. The controller's step method will then be invoked steps times or until the life force is depleted.
controller - the SimpleWorldRobotController that is to be used to
control the robot.steps - the number of steps to run. Use -1 to run until lifeforce is
depleted.
Exception - if there is an exception starting the controller or
invoking step.
|
dLife Home Page | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||