Embed
Email

AI and Game Programming

Document Sample
AI and Game Programming
Shared by: pptfiles
Categories
Tags
Stats
views:
2
posted:
10/27/2011
language:
English
pages:
16
AI and Game

Programming





Unreal Tournament Project

Introduction

 UT is a FPS



 The competition

• Domination mode

• Domination points

• Teams of 3 bots

• First team to 100

points wins

Getting Started

 Installation:

• UT standalone server

• GameBots

• ActiveTcl

• TclViz

• JBuilder Foundation

• Javabots

• JRE v1.5.0_05

• Misc.

Running an Experiment





3. Start Javabot









2. Start the vis. tool









1. Start the server

Creating a Bot

 Copy your BotTemplate.java to the directory:

C:/…/jbproject/javabot/src/edu/lu

 Change the file name to .java

 Start JBuilder Foundation

 Open the Javabot project (javabot.ipx)

 Select the package edu.lu

• If .java does not appear, refresh the project

 Edit the template

 Rebuild the project

UT Basics

 All units are absolute UT units – no bearing to

real world units

• Bot’s collision cylinder: 39 units tall with a radius of 17

units

• Full rotation: 65535

• Radians: (UT_Rotation_Amt / 65535) * 2π

 Locations and Orientations

• x,y,z

• pitch, yaw, roll

• up and down, side to side, cartwheel

Server Messages

 Format:

• MSG_TYP {ATTRIB_TYP ATTRIB_VAL} {…}

• Ex. DOM {Id 1} {Location 23,43,13} {Controller 1}

• Attribute values returned as strings



 2 Types of Messages

• Synchronous

• Asynchronous

Server Messages cont.

 Synchronous Messages:

• Sent in batches at regular intervals

• First message is type BEG, last is type END

• Constitute one atomic game state

• Ex. Visual updates, bot status reports

 Asynchronous Messages:

• Single messages, generated as events occur

• Cannot arrive during sync. message block

• Ex. Took damage, picked up a weapon

Client Commands

 Use same format as server messages

 Commands have persistent effects

• Ex. Start shooting, keep shooting until a stop

shooting command is sent

Programming

 2 Tasks, 2 Threads

• Message handling

• FSM



 Message Handling – two functions

• receivedSyncMessage()

• receivedAsyncMessage()



 FSM – one function

• runner.run()

Programming cont.

 Multithreaded:

• One thread handles messages

• One thread handles the FSM (runner)

• May need to use semaphores (synchronized) to avoid race

conditions and such



protected Object stateLock = new Object();

someMethod() {



synchronized (stateLock) {

// shared variable manipulation

}

}

Programming cont.

 Handling messages:



Message m;

String type, value;

type = m.getType();

switch(type) {…}

value = m.getProperty(PROP_ID);

Programming cont.

 Most commands can be sent with

existing function calls (ie. runTo(x,y,z)



 Manually sending commands:



Properties props;

props.setProperty(ATTRIB_TYP,ATTRIB_VAL);

client.sendMessage(MSG_TYP, props);

Random helpful info.

 edu.isi.gamebots.client.GamebotConstants,

contains definitions of all the constants

for MSG_TYP, and ATTRIB_TYP



 Use log() to print to the Javabot text area

• Note: change enableLog to false before

submitting your final bot (or manually delete

all your log() calls)

Server Adminstration

 You can set server settings and monitor

your server through a web browser.

• After starting the server open a browser and

connect to:

127.0.0.1:8888/Administer

Username: Admin

Password: Admin

Random helpful info.

 Sync. message blocks contain DOM messages

• Contain the coordinates of a domination pt.

• Tells who controls the domination pt.

• Use getPath(x,y,z) to get directions to a DOM pt.





 IMPORTANT: must tell the javabot client

about your bot!

• Open edu.isi.gamebots.client.BotRunnerApp

• Locate the knownBots data structure

• Add the full name of your bot to the array


Shared by: pptfiles
Other docs by pptfiles
FRONT OFFICE OPERATIONS MANAGEMENT_1_
Views: 30  |  Downloads: 0
Fracture Management
Views: 12  |  Downloads: 0
Forest Management
Views: 15  |  Downloads: 0
Forest Biosecurity and Risk Management
Views: 12  |  Downloads: 0
Related docs
By registering with docstoc.com you agree to our
privacy policy

You are almost ready to download!

You are almost ready to download!