All Packages Class Hierarchy This Package Previous Next Index
Class ch.jp.robwar.AsynchronousBrainInterface
java.lang.Object
|
+----ch.jp.robwar.BrainInterface
|
+----ch.jp.robwar.AsynchronousBrainInterface
- public class AsynchronousBrainInterface
- extends BrainInterface
- implements Runnable
This class build on the BrainInterface to provide
an interface that gets rid of the 'steps' limitation.
-
myThread
-
-
robInput
-
-
robInstructions
-
-
worldInterfaceLock
-
The external robot and the simulation use this semaphore
so that reality cannot be altered in the middle of a step
-
AsynchronousBrainInterface(RobotBrain)
- Nothing special about the constructor.
-
nextMove(Feedback)
- This will return the current robot's desire and update
its perception of the world.
-
run()
- This method, meant to be called by
(new AsynchronousBrainInterface(myBrain)).run(),
Continuously calls the brain's nextMove method
and accumulates the results (think logical OR).
robInstructions
protected Instructions robInstructions
robInput
protected Feedback robInput
worldInterfaceLock
protected Object worldInterfaceLock
- The external robot and the simulation use this semaphore
so that reality cannot be altered in the middle of a step
myThread
protected Thread myThread
AsynchronousBrainInterface
public AsynchronousBrainInterface(RobotBrain newBrain)
- Nothing special about the constructor. However
remember that this class is not used the same way as
its parents (namely, you have to start() this one)
run
public void run()
- This method, meant to be called by
(new AsynchronousBrainInterface(myBrain)).run(),
Continuously calls the brain's nextMove method
and accumulates the results (think logical OR).
When BrainInterface.nextMove is called, it will
return this aggregated Instructions, and be given
new Stimuli. This stimuli will be passed to the
next nextMove and then blanked (think AND 0).
the time stimuli will remain the same, allowing
the RobotBrain to detect when new Stimuli are
fed to it.
The first thing this method does is suspend: it waits
for nextMove() to be called for the first time with some
input before it can start the robot and relay this world
view to it.
I will provide a nice method to stop the BrainInterface
someday when I see a use for it. Until then,
use stop().
This approach may not be perfect, and I may
change it someday, especially if/when I decide
to get rid of the notion of "step" altogether.
nextMove
public Instructions nextMove(Feedback senses)
- This will return the current robot's desire and update
its perception of the world. This represents a step.
- Overrides:
- nextMove in class BrainInterface
All Packages Class Hierarchy This Package Previous Next Index