edu.isi.gamebots.examples
Class ExampleBot

java.lang.Object
  |
  +--edu.isi.gamebots.client.Bot
        |
        +--edu.isi.gamebots.examples.ExampleBot
All Implemented Interfaces:
GamebotsConstants

public class ExampleBot
extends Bot

This example implementation the Bot class shows basic message handling, Bot control, and and uses UTMapUI for a map in its user interface.

Author:
Andrew n marshall

Nested Class Summary
protected  class ExampleBot.Node
           
protected  class ExampleBot.NodeMap
           
protected  class ExampleBot.Path
           
 
Nested classes inherited from class edu.isi.gamebots.client.GamebotsConstants
GamebotsConstants.TeamColorMap
 
Field Summary
protected  int ammo
           
protected  int armor
           
protected  boolean didInit
           
protected  int direction
           
protected  Set exploredNodes
           
protected static int EXPLORING
           
protected static int HEALING
           
protected  int health
           
protected  Vector3D here
           
protected static int HUNTING
           
protected  Map idToNode
           
protected  boolean interfered
           
protected static int INTERFERENCE_BUMP
           
protected static int INTERFERENCE_DAMAGE
           
protected static int INTERFERENCE_WALL
           
protected  long interferenceTime
           
protected  int interferenceType
           
protected  Collection knownNodes
           
protected  long lastRotIncTime
           
protected  ExampleBot.Node lastTarget
           
protected static int LEFT
           
protected  boolean logIntents
           
protected  boolean logMessages
           
protected  boolean logSelf
           
protected  ExampleBot.NodeMap map
           
protected static int MAX_OUTPUT
           
protected  Object nodeInfoLock
           
protected static int NONE
           
protected static Comparator pathComparator
          Compares Paths based on theta.
protected  double pitch
           
protected static double PLAYER_RADIUS
           
protected  Random random
           
protected  Set reachableNodes
           
protected static int RIGHT
           
protected  double roll
           
protected  Runnable runner
           
protected  Thread runnerThread
           
protected  Object selfLock
          This lock is used to synchronized reads from/writes to the various state variables.
protected  int state
           
protected  long stateChangeTime
           
protected  Object stateLock
           
protected  ExampleBot.Node target
           
protected  long targetAcquiredTime
           
protected  long targetLostTime
           
protected  int team
           
protected static double THETA_DELTA
           
protected  Set visibleNodes
           
protected  String weapon
           
protected  double x
           
protected  double y
           
protected  double yaw
           
protected  double yawTarget
           
protected  double z
           
 
Fields inherited from class edu.isi.gamebots.client.Bot
client, clientListener, eventProcessor, log
 
Fields inherited from interface edu.isi.gamebots.client.GamebotsConstants
ACTOR_CLASS, ACTOR_ID, ACTOR_REACHABLE, ARG_ALT, ARG_AMOUNT, ARG_GLOBAL, ARG_TARGET, ARG_TEXT, ARG_WALK, BEG, BUMP, CHANGEWEAPON, CHECKREACH, DAMAGE, DEATH_DAMAGE_TYPE, DEATH_KILLER, DEFAULT_BOT_PORT, DEFAULT_VIZ_PORT, DIE, DOM, DOMPOINTS, END, FALSE, FINISHED, GAMESTATE, GETPATH, INFO, INIT, INV, ITEM, ITEM_ID, JUMP, KILL, LOCATION, MESSAGE, MOV, NAV, NODE_DOMINATION, NODE_INVENTORY, NODE_MOVER, NODE_NAVIGATION, OWNER, PATH, PING, PLAYER, PLAYER_AMMO, PLAYER_ARMOR, PLAYER_HEALTH, PLAYER_NAME, PLAYER_TEAM, PLAYER_WEAPON, PONG, ROTATE, ROTATION, RUNTO, SEE, SELF, SETWALK, SHOOT, STOP, STOP_SHOOT, STRAFE, TEAM_ANY, TEAM_BLUE, TEAM_GOLD, TEAM_GREEN, TEAM_NONE, TEAM_RED, TRUE, TURNTO, VELOCITY, WALL, WEAPON_1, WEAPON_2
 
Constructor Summary
ExampleBot()
           
 
Method Summary
protected  void connected()
           Bot implementations override this to specify what to do (if anything) after the bot established a server connection.
protected  void disconnected()
           Event handling.
protected  void explore()
           
protected  void findNewTarget()
           
 JComponent getView()
           Returns a user interface for the bot.
protected  void heal()
           
protected  void hunt()
           
protected  void incRotation()
           
protected  void jitter()
           
protected  void receivedAsyncMessage(Message message)
           Bot implementations must override this method.
protected  void receivedSyncMessage(MessageBlock block)
           Bot implementations must override this method.
protected  void updateSelf(Message message)
           
 
Methods inherited from class edu.isi.gamebots.client.Bot
changeWeapon, checkReach, checkReach, connect, destroy, destroyImpl, disconnect, getClient, getInitialTeam, getLog, getName, getPath, init, init, jump, parseVector, receivedError, rotate, runTo, runTo, say, setName, setWalk, shoot, shoot, shoot, stop, stopShoot, strafe, turnTo, turnToLoc, turnToLoc
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MAX_OUTPUT

protected static final int MAX_OUTPUT
See Also:
Constant Field Values

PLAYER_RADIUS

protected static final double PLAYER_RADIUS
See Also:
Constant Field Values

THETA_DELTA

protected static final double THETA_DELTA
See Also:
Constant Field Values

NONE

protected static final int NONE
See Also:
Constant Field Values

EXPLORING

protected static final int EXPLORING
See Also:
Constant Field Values

HEALING

protected static final int HEALING
See Also:
Constant Field Values

HUNTING

protected static final int HUNTING
See Also:
Constant Field Values

INTERFERENCE_BUMP

protected static final int INTERFERENCE_BUMP
See Also:
Constant Field Values

INTERFERENCE_WALL

protected static final int INTERFERENCE_WALL
See Also:
Constant Field Values

INTERFERENCE_DAMAGE

protected static final int INTERFERENCE_DAMAGE
See Also:
Constant Field Values

LEFT

protected static final int LEFT
See Also:
Constant Field Values

RIGHT

protected static final int RIGHT
See Also:
Constant Field Values

pathComparator

protected static final Comparator pathComparator
Compares Paths based on theta. Note: this comparator imposes orderings that are inconsistent with equals(...).


map

protected ExampleBot.NodeMap map

random

protected Random random

runnerThread

protected Thread runnerThread

logIntents

protected boolean logIntents

logMessages

protected boolean logMessages

logSelf

protected boolean logSelf

didInit

protected boolean didInit

stateLock

protected Object stateLock

stateChangeTime

protected long stateChangeTime

state

protected int state

direction

protected int direction

selfLock

protected final Object selfLock
This lock is used to synchronized reads from/writes to the various state variables.


x

protected double x

y

protected double y

z

protected double z

yaw

protected double yaw

pitch

protected double pitch

roll

protected double roll

health

protected int health

armor

protected int armor

ammo

protected int ammo

team

protected int team

weapon

protected String weapon

here

protected Vector3D here

interfered

protected boolean interfered

interferenceTime

protected long interferenceTime

interferenceType

protected int interferenceType

lastRotIncTime

protected long lastRotIncTime

yawTarget

protected double yawTarget

nodeInfoLock

protected Object nodeInfoLock

idToNode

protected Map idToNode

knownNodes

protected Collection knownNodes

exploredNodes

protected Set exploredNodes

visibleNodes

protected Set visibleNodes

reachableNodes

protected Set reachableNodes

target

protected ExampleBot.Node target

lastTarget

protected ExampleBot.Node lastTarget

targetAcquiredTime

protected long targetAcquiredTime

targetLostTime

protected long targetLostTime

runner

protected Runnable runner
Constructor Detail

ExampleBot

public ExampleBot()
Method Detail

getView

public JComponent getView()
Description copied from class: Bot

Returns a user interface for the bot. This is needed if you want to use the BotRunnerApp to start and view the status of your bots. The JComponent that this returns is what gets added to a new tab in the interface.

Overrides:
getView in class Bot
Returns:
a Swing user interface for the bot.

connected

protected void connected()
Description copied from class: Bot

Bot implementations override this to specify what to do (if anything) after the bot established a server connection.

Overrides:
connected in class Bot

receivedAsyncMessage

protected void receivedAsyncMessage(Message message)
Description copied from class: Bot

Bot implementations must override this method. This specifies what to do when an asynchronous message is recieved. A description of the difference between sync and async messages can be found at http://www.planetunreal.com/gamebots/docapi.html. Although this is not nessesarily a complete reference, it is a good general intro.

Specified by:
receivedAsyncMessage in class Bot
Parameters:
message - The Message object to handle

receivedSyncMessage

protected void receivedSyncMessage(MessageBlock block)
Description copied from class: Bot

Bot implementations must override this method. This specifies what to do when an synchronous message is recieved. A description of the difference between sync and async messages can be found at http://www.planetunreal.com/gamebots/docapi.html. Although this is not nessesarily a complete reference, it is a good general intro.

Specified by:
receivedSyncMessage in class Bot
Parameters:
block - The synchronous MessageBlock to handle

disconnected

protected void disconnected()
Description copied from class: Bot

Event handling. Bot implementation overrides this to tell what to do when disconnected from the server.

Overrides:
disconnected in class Bot

updateSelf

protected void updateSelf(Message message)

explore

protected void explore()

heal

protected void heal()

hunt

protected void hunt()

findNewTarget

protected void findNewTarget()

incRotation

protected void incRotation()

jitter

protected void jitter()