edu.cmu.gamebots
Class CMU_JBot

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

public class CMU_JBot
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
, Steve Schaffer ,
Nested Class Summary
protected  class CMU_JBot.Node
           
protected  class CMU_JBot.NodeMap
           
protected  class CMU_JBot.Path
           
 
Nested classes inherited from class edu.isi.gamebots.client.GamebotsConstants
GamebotsConstants.TeamColorMap
 
Field Summary
protected  int ammo
           
protected  int armor
           
protected  boolean askPath
           
protected  boolean didInit
           
protected  int direction
           
protected  String dom1id
           
protected  Vector3D dom1loc
           
protected  int dom1owner
           
protected  String dom2id
           
protected  Vector3D dom2loc
           
protected  int dom2owner
           
protected  String dom3id
           
protected  Vector3D dom3loc
           
protected  int dom3owner
           
protected static int DOMINATING
           
protected  Message domPath
           
protected  int domPathStep
           
protected  int domsfound
           
protected  int domTarget
           
protected  long domTargetChangeTime
           
protected  Set exploredNodes
           
protected static int EXPLORING
           
protected  boolean gotWeapon
           
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  CMU_JBot.Node lastTarget
           
protected static int LEFT
           
protected  boolean logIntents
           
protected  boolean logMessages
           
protected  boolean logSelf
           
protected  CMU_JBot.NodeMap map
           
protected static int MAX_OUTPUT
           
protected  Object nodeInfoLock
           
protected static int NONE
           
protected static Comparator pathComparator
          Compares Paths based on theta.
protected  long pathRelock
           
protected  double pitch
           
protected static double PLAYER_RADIUS
           
protected  Vector3D previousHere
           
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 shotTime
           
protected  int state
           
protected  long stateChangeTime
           
protected  Object stateLock
           
protected  CMU_JBot.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
CMU_JBot()
           
 
Method Summary
protected  int chooseDomTarget()
           
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 dominate()
           
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  Vector3D parseStep(Message message, int step)
           
protected  void pathTo(double x, double y, double z)
           
protected  void receivedAsyncMessage(Message message)
           Bot implementations must override this method.
protected  void receivedSyncMessage(MessageBlock block)
           Bot implementations must override this method.
protected  void shootAt(String target)
           
protected  void stopShooting()
           
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

DOMINATING

protected static final int DOMINATING
See Also:
Constant Field Values

shotTime

protected int shotTime

gotWeapon

protected boolean gotWeapon

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 CMU_JBot.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 CMU_JBot.Node target

lastTarget

protected CMU_JBot.Node lastTarget

targetAcquiredTime

protected long targetAcquiredTime

targetLostTime

protected long targetLostTime

domTargetChangeTime

protected long domTargetChangeTime

pathRelock

protected long pathRelock

domTarget

protected int domTarget

domsfound

protected int domsfound

dom1id

protected String dom1id

dom2id

protected String dom2id

dom3id

protected String dom3id

dom1loc

protected Vector3D dom1loc

dom2loc

protected Vector3D dom2loc

dom3loc

protected Vector3D dom3loc

dom1owner

protected int dom1owner

dom2owner

protected int dom2owner

dom3owner

protected int dom3owner

previousHere

protected Vector3D previousHere

domPath

protected Message domPath

domPathStep

protected int domPathStep

askPath

protected boolean askPath

runner

protected Runnable runner
Constructor Detail

CMU_JBot

public CMU_JBot()
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()

dominate

protected void dominate()

parseStep

protected Vector3D parseStep(Message message,
                             int step)

pathTo

protected void pathTo(double x,
                      double y,
                      double z)

chooseDomTarget

protected int chooseDomTarget()

shootAt

protected void shootAt(String target)

stopShooting

protected void stopShooting()

findNewTarget

protected void findNewTarget()

incRotation

protected void incRotation()

jitter

protected void jitter()