com.threerings.parlor.util
Class RobotPlayer

java.lang.Object
  extended by com.samskivert.util.Interval
      extended by com.threerings.parlor.util.RobotPlayer

public class RobotPlayer
extends Interval

The robot player is a computer player with truly rudimentary artificial intelligence that periodically posts random commands selected from the available key press and release commands to the target component. Note that Robot could have been used to post key events to the target component rather than commands, but not all key events can be simulated in that fashion (e.g., a right shift key press), and this seemed somehow more proper in any case.


Nested Class Summary
 
Nested classes/interfaces inherited from class com.samskivert.util.Interval
Interval.Factory, Interval.IntervalTask, Interval.RunBuddy
 
Field Summary
protected  boolean _active
          Whether the robot is active or not.
protected  List<String> _press
          The list of available key press action commands.
protected  List<String> _release
          The list of available key release action commands.
protected  long _robotDelay
          The milliseconds between posting each action command.
protected  Component _target
          The target component associated with game action commands.
protected  KeyTranslator _xlate
          The key translator that describes available keys and commands.
protected static long DEFAULT_ROBOT_DELAY
          The default robot delay.
 
Fields inherited from class com.samskivert.util.Interval
_runQueue, _task, _timer, RUN_DIRECT
 
Constructor Summary
RobotPlayer(Component target, KeyTranslator xlate)
          Constructs a robot player.
 
Method Summary
 void expired()
           
 boolean isActive()
          Returns whether the robot is currently active and periodically posting action commands.
 void setActive(boolean active)
          Sets whether the robot player is actively posting action commands.
 void setRobotDelay(long delay)
          Sets the delay in milliseconds between posting each action command.
 
Methods inherited from class com.samskivert.util.Interval
cancel, create, createTimer, noteRejected, safelyExpire, schedule, schedule, schedule, schedule, schedule, scheduleTask, setRunQueue
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_ROBOT_DELAY

protected static final long DEFAULT_ROBOT_DELAY
The default robot delay.

See Also:
Constant Field Values

_active

protected boolean _active
Whether the robot is active or not.


_robotDelay

protected long _robotDelay
The milliseconds between posting each action command.


_press

protected List<String> _press
The list of available key press action commands.


_release

protected List<String> _release
The list of available key release action commands.


_xlate

protected KeyTranslator _xlate
The key translator that describes available keys and commands.


_target

protected Component _target
The target component associated with game action commands.

Constructor Detail

RobotPlayer

public RobotPlayer(Component target,
                   KeyTranslator xlate)
Constructs a robot player.

Method Detail

setActive

public void setActive(boolean active)
Sets whether the robot player is actively posting action commands.


setRobotDelay

public void setRobotDelay(long delay)
Sets the delay in milliseconds between posting each action command.


isActive

public boolean isActive()
Returns whether the robot is currently active and periodically posting action commands.


expired

public void expired()
Specified by:
expired in class Interval