|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--edu.isi.gamebots.client.Bot
This is the base class for all Java Bots. It handles most low level functionality, including bot life cycle hooks, and many helper functions.
Nested Class Summary |
Nested classes inherited from class edu.isi.gamebots.client.GamebotsConstants |
GamebotsConstants.TeamColorMap |
Field Summary | |
protected GamebotsClient |
client
The UTServer |
protected GamebotsClient.Listener |
clientListener
Handles server message events |
protected Runnable |
eventProcessor
Processes events as they arrive |
protected us.ca.la.anm.util.io.DebugLog |
log
A logging mechanisn |
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_RADIUS, 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 | |
Bot()
Creates a new Bot |
Method Summary | |
void |
changeWeapon(String weaponID)
Changes to another weapon that the agent posseses. |
void |
checkReach(String id,
double fromX,
double fromY,
double fromZ)
check to see if you can move directly to a destination without hitting an obstruction, falling in a pit, etc... |
void |
checkReach(String id,
String target)
check to see if you can move directly to a destination without hitting an obstruction, falling in a pit, etc... |
void |
connect()
This initiates a connection with the server. |
protected void |
connected()
Bot implementations override this to specify what to do (if anything) after the bot established a server connection. |
void |
destroy()
Event Handler. |
protected void |
destroyImpl()
Event handling. |
void |
disconnect()
This forces disconnect with the server. |
protected void |
disconnected()
Event handling. |
GamebotsClient |
getClient()
Get the server that this bot is running on. |
int |
getInitialTeam()
Return the name of the team that the bot was initialized to. |
us.ca.la.anm.util.io.DebugLog |
getLog()
Return the log for the bot |
String |
getName()
Get the bot's name |
void |
getPath(String pathName,
double x,
double y,
double z)
The bot asks for a path to an xyz coordinate |
JComponent |
getView()
Returns a user interface for the bot. |
protected void |
init()
Bot implementations override this to specify what to do (if anything) when the bot is initialized. |
void |
init(String name,
GamebotsClient client,
int team,
us.ca.la.anm.util.io.DebugLog log)
Main initialization method for BotRunnerApp . |
void |
jump()
The agent jumps. |
static double[] |
parseVector(String in)
Parses any comma or space delimited list of numbers into an array of doubles. |
protected abstract void |
receivedAsyncMessage(Message message)
Bot implementations must override this method. |
protected void |
receivedError(Throwable error)
Event handling. |
protected abstract void |
receivedSyncMessage(MessageBlock message)
Bot implementations must override this method. |
void |
rotate(double amount)
Rotate the agent by a particular amount. |
void |
runTo(double x,
double y,
double z)
The bot runs to a perticular location |
void |
runTo(String target)
The bot runs to a perticular target. |
void |
say(String message,
boolean forEveryone)
Say something that is heard by other players. |
protected void |
setName(String newName)
Sets the bot's name. |
void |
setWalk(boolean doWalk)
Set the agent to walk instead of run. |
void |
shoot()
Agent shoots their current weapon (if they have one). |
void |
shoot(double x,
double y,
double z,
String targetID,
boolean altFire)
Shoot at a particular target. |
void |
shoot(String targetID,
boolean altFire)
Shoot at a particular target. |
void |
stop()
Stop moving. |
void |
stopShoot()
If currently shooting its weapon, the bot will stop. |
void |
strafe(double x,
double y,
double z,
String faceObjectID)
Strafe. |
void |
turnTo(double pitch,
double yaw,
double roll)
Turn a particular amount in three dimentional space. |
void |
turnToLoc(double x,
double y,
double z)
Turn towards a particular location in space |
void |
turnToLoc(String coords)
Turn towards a particular location in space |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
protected GamebotsClient client
The UTServer
protected us.ca.la.anm.util.io.DebugLog log
A logging mechanisn
protected GamebotsClient.Listener clientListener
Handles server message events
protected Runnable eventProcessor
Processes events as they arrive
Constructor Detail |
public Bot()
Creates a new Bot
Method Detail |
public static double[] parseVector(String in) throws NumberFormatException
Parses any comma or space delimited list of numbers into an array of doubles. Particularly useful for parsing location and rotation information.
in
- The String object to parse
NumberFormatException
- If there is a non-number in the listpublic final void init(String name, GamebotsClient client, int team, us.ca.la.anm.util.io.DebugLog log)
Main initialization method for BotRunnerApp
. All Bot specific
initialization should occur in init(java.lang.String, edu.isi.gamebots.client.GamebotsClient, int, us.ca.la.anm.util.io.DebugLog)
.
name
- Name of the botclient
- UTServer that bot talks toteam
- Team that the bot is onlog
- Where to log debug messages to (can specify System.out to log to the console)public final String getName()
Get the bot's name
public final GamebotsClient getClient()
Get the server that this bot is running on.
GamebotsClient
.public final int getInitialTeam()
Return the name of the team that the bot was initialized to.
int
team that the bot belongs topublic JComponent getView()
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.
public final void connect()
BotRunnerApp
.
public final void disconnect()
BotRunnerApp
.
public final void destroy()
Event Handler. Override this method to define what to do when the bot is distroyed/disconnected by the user.
public void runTo(String target)
The bot runs to a perticular target.
target
- The UnrealTournament ID to run topublic void getPath(String pathName, double x, double y, double z)
The bot asks for a path to an xyz coordinate
public void runTo(double x, double y, double z)
The bot runs to a perticular location
x
- global x coordinate in the worldy
- global y coordinate in the worldz
- global z coordinate in the worldpublic us.ca.la.anm.util.io.DebugLog getLog()
Return the log for the bot
DebugLog
of the agentpublic void turnTo(double pitch, double yaw, double roll)
Turn a particular amount in three dimentional space. Yaw is side to side, pitch up and down, and Roll the equivelent of doing a cartwheel. You probably won't need Roll, so don't sweat it. A full rotation using UT's measurements is 65535. To convert the values you are sent to radiens, divide by 65535 and multiply by 2 * pi. This is already converted for you to radians though. UnrealTournament units.
pitch
- Amount to look up or down in radiansyaw
- Amount to turn side to side in radiansroll
- Amount of 'roll' rotation. Not sure what this does.public void turnToLoc(double x, double y, double z)
Turn towards a particular location in space
x
- The global x coordinate to turn towardy
- The global y coordinate to turn towardz
- The global z coordinate to turn towardpublic void turnToLoc(String coords)
Turn towards a particular location in space
coords
- Same as turnTo(double, double, double) except this takes the three corrdinates as a single string.public void setWalk(boolean doWalk)
Set the agent to walk instead of run. It seems intuitive that when true is sent, the agent should walk. But in our tests, it seems the agent is set to run when true is sent and walks when false is sent.
doWalk
- We think that true
means run and false
means walk.public void say(String message, boolean forEveryone)
Say something that is heard by other players.
message
- The message to sendforEveryone
- True if this is sent to both teams, false if only to
your teampublic void stop()
Stop moving. If the agent is en route to a location (via the runTo) command or is otherwise moving and can stop, the agent will stop.
public void jump()
The agent jumps. I think that it is a bug that the bot is able to jump again while in the middle of a jump. In a room with high celings this gives bots magical flying ability.
public void strafe(double x, double y, double z, String faceObjectID)
Strafe. This causes the agent to run to a particular location while looking at another.
x
- Global x coordinate run to.y
- Global y coordinate run to.z
- Global z coordinate run to.faceObjectID
- Object ID to face while runningpublic void rotate(double amount)
Rotate the agent by a particular amount. A full rotation using UT's measurements is 65535. To convert the values you are sent to radiens, divide by 65535 and multiply by 2 * pi.
amount
- Amount in UT units to rotatepublic void shoot()
Agent shoots their current weapon (if they have one). Sometimes the agent will fire one or two shots and sometimes they fire more.
public void shoot(double x, double y, double z, String targetID, boolean altFire)
Shoot at a particular target. The bot will auto aim. As long as the target
stays within the bots visual range, the bot will keep shooting the target until
it runs out of ammo. Use the {stopShoot
command to stop shooting.
x
- Global x coordinate to fire towardy
- Global y coordinate to fire towardz
- Global z coordinate to fire towardtargetID
- Global UT target ID to fire ataltFire
- true
to use the weapon's alternate fire feature.public void shoot(String targetID, boolean altFire)
Shoot at a particular target. The bot will auto aim. As long as the target
stays within the bots visual range, the bot will keep shooting the target until
it runs out of ammo. Use the stopShoot
command to stop shooting.
targetID
- The UT id of the target to shoot ataltFire
- true
to use the weapon's alternate fire feature.public void changeWeapon(String weaponID)
Changes to another weapon that the agent posseses.
weaponID
- The UT id of the weapon to switch topublic void stopShoot()
If currently shooting its weapon, the bot will stop.
protected void setName(String newName)
Sets the bot's name. Currently does nothing if the Bot is already connected.
Future: request name changes to the server when connected.
newName
- Agent nameprotected void init()
Bot implementations override this to specify what to do (if anything) when the bot is initialized.
protected void connected()
Bot implementations override this to specify what to do (if anything) after the bot established a server connection.
protected abstract void receivedAsyncMessage(Message message)
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.
message
- The Message
object to handleprotected abstract void receivedSyncMessage(MessageBlock message)
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.
message
- The synchronous MessageBlock
to handleprotected final void receivedError(Throwable error)
Event handling. What to do when a bot throws an error. Default is to disconnect.
error
- The error that was recieved to handle.protected void disconnected()
Event handling. Bot implementation overrides this to tell what to do when disconnected from the server.
protected void destroyImpl()
Event handling. Describes what to do when the bot is destroyed.
public void checkReach(String id, String target)
check to see if you can move directly to a destination without hitting an obstruction, falling in a pit, etc...
id
- message id made up by you and echoed in respose so you can match up response with querrytarget
- the unique id of a player/object/nav point/whatever. Must be visible.public void checkReach(String id, double fromX, double fromY, double fromZ)
check to see if you can move directly to a destination without hitting an obstruction, falling in a pit, etc...
id
- message id made up by you and echoed in respose so you can match up response with querryfromX
- Location you want to go to. Normal location rules.fromY
- Location you want to go to. Normal location rules.fromZ
- Location you want to go to. Normal location rules.
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |