300 likes | 470 Views
AI Bot for First Person Shooters. João Carlos Gonçalves jcgonc@student.dei.uc.pt. OMNI-BOT - Resume. Bots Resume Omni-Bot Game functioning, Framework Agent structure, Goals Society and interaction between agents, Waypoints and traversal, Manual routing, Scripting,
E N D
AI Bot for First Person Shooters João Carlos Gonçalves jcgonc@student.dei.uc.pt
OMNI-BOT - Resume • Bots • Resume Omni-Bot • Game functioning, • Framework • Agent structure, • Goals • Society and interaction • between agents, • Waypoints and traversal, • Manual routing, • Scripting, • Problems and scripting, • Conclusion
What’s a bot? • Everyone who has played a computer game has encountered a bot. • Computer controlled game player. • Computational equivalent of a ‘robot’ Bot Agent
Why bots? • Fill a game with more players. • Help humans to train. • Execute tasks boring for us. • Etc.
OMNI-BOT Framework implementing bots in FPS • Games supported: Wolfenstein: Enemy Territory, Doom 3, Quake 4, Fortress Forever, Return To Castle Wolfenstein, Team Fortress 2 • “BDI” agents, internally state machines. Oriented towards completing goals while sensing their environment. Not ALL games fully working (currently). Best implementation on W.E.T.
Enemy Territory- Resume - • Comprised of various environments (maps) usually set in WW2, with different goals (frequently contradictory) for the factions. • Two factions: Allies and Axis, equal in characteristics, spawning in pre-determinated locations. • Five classes: Soldier, Medic, Engineer, Field Ops, Covert Ops, each one with it’s advantages and disadvantages.
Wolfenstein – Enemy Territory- Goals - • Goals like stealing vehicles, escorting or not allowing them to move, destroying or constructing entities, healing and reviving teammates, etc. • Completing goals may create contradictory goals on the opposing faction. • Game development may also create or delete goals, possibly specific for some faction. • Show Demo.
Wolfenstein – Enemy Territory • Limbo, with map’s goals for allied faction:
Wolfenstein – ET : MODs • SDK for changing game logic available • Various game modifications (mods) with different game plays: • ETPub • NoQuarter • ShrubMod • ETPro • Jaymod • True Combat Elite • PowerBall • etc. • Installed on the game’s directory
OMNI-BOT Independent ‘Library’ installed on ET’s folder (usually “omni-bot”) • “omnibot_et.dll has the implementation • “qagame_mp_x86.dll” = server side engine (game logic) • “cgame_mp_x86.dll” & “ui_mp_x86.dll” = client side engine and graphics (client side logic and corresponding graphics) “Omnibot_et.dll” linked by the running mod (must support omni’s interface) • mod initializes omnibot and bots are connected to the engine as clients (like players) • supported mods: ETPub, Jaymod, NoQuarter
OMNI-BOT - agent structure • List of goals, with execution states, positions, priorities and availability • Sensory memory, with list of attractive entities, like enemies or ‘aimable’ things. • Available weapons, with their preference and firing parameters. • Motor Control, executing the path following algorithm as well as the aiming mechanism.
OMNI-BOT - agent structure • Simplified version of a BDI agent • Beliefs = Stored on sensory memory • Desires = List of goals • Intentions = desire selected for execution, being performed • Basically a state machine (deterministic finite automaton, DFA)
OMNI-BOT - State Tree • Show bigger state tree
OMNI-BOT – Agent’s behaviour if(incapacitated) { do { for(medic:team.medics) { evaluation = avaliate(medic.proximity); } evaluation = avaliate(timer.spawn); decideRespawn(evaluation); selectEquipment(); } while(incapacitated); } else { updateSensoryMemory(world.getNeighborhood()); // additional behaviour scripts executeScripts(); selectEquipment(); goal = getHighestPriorityAvailableGoal(); // goal may include alternative route path = computePath(goal); // wait for world events while(not(world.changed)) { waypoint = nearestWaypoint(path); motorControl.setDestination(waypoint); if(near(waypoint)) { do { execute(goal); } while(not(executed(goal))); } }; }; • Simplified algorithm for bots' behaviour. Actually implemented in parallel threads, like path following, enemy aiming and firing, sensory information, etc. (external scripts)
OMNI-BOT – Agent’s behaviour • Executed on each server frame (usually 20 per second, server side cvar “sv_fps”) • ‘Threads’ and execution details on Debug’s window, section profiler
OMNI-BOT - Goals • Retrieved from the map’s script and bsp’s entities • Following example: destroy ‘Side Door’, for axis
OMNI-BOT - Goals • Example of map goals: • x: “goal” -> |bitflag| serial |y| priority |z| • bitflag specifying allowed team (axis, allies); • serial = internal goal identification; • priority = goal priority (relating to others). • and more properties
OMNI-BOT - Society • By default goals are shared by different agents (excluding some cases). • If not, the goal is assigned by the framework to some agent (actually, first come, first served). • An agent may require support from others (ammunition and health / revival). In this case, it creates a specific goal (like ‘heal me’). • No negotiation of goals between the agents. Individual behaviour
OMNI-BOT - Waypoints • Goals are reached by following paths • Paths created using waypoints • Directed graphs (typically cyclic) • Diagonal descending edge = connection direction
OMNI-BOT - Waypoints Travelling properties (flags): • Crouch, prone, sprint, walk, jump, route, radius, etc. • radius of waypoint affects path cornering • waypoint flag affects bot‘s behaviour when it’s approaching the node or when reaches it’s radius
OMNI-BOT – Path travelling Uses Dijkstra's algorithm for waypoint selection Essentially uses the shortest path from the source (where the agent selected the goal) to it’s destination (where goal resides or next route point if used)
OMNI-BOT – Routing • Path travelling easily expected • Boring for humans • Solution = Manual routing Basically a human ‘codes’ different paths for different map traversal Goal X = travel through waypoint 1, then 2 OR 3, then 4, etc. until reach destination • Define waypoint selection probability • Route is chosen when goal acquired near ‘first’ route waypoint.
OMNI-BOT – Routing From ‘SPAWN’ to ‘GOAL’: MapRoutes = { GOAL = { ROUTE_SPAWN = { ROUTE_A = {Weight = 2.0,}, ROUTE_B = {}, ROUTE_C = {Weight = 0.66 ROUTE_B = {Weight = 0.5} ROUTE_D = {}, },},},}; • If ‘goal’ got when at ‘spawn’ waypoint, choose next waypoint from A, B or C, with probabilities of 2, 1 and 0.66. Calculate shortest path to chosen route point and travel the path; • When arrive to A or B, travel shortest path to ‘goal’s waypoint; • If chose waypoint C and reached it, choose B or D (with corresponding probabilities) and calculate shortest path to ‘goal’. Then travel it.
OMNI-BOT – Scripting • Written in GameMonkey language • Add functionality to goals, maps, weapons, bots, utils, etc. • Goal scripts: Tells or helps the bot how to achieve some goal (map or another); • Map scripts: Control the logic of the map, like enabling or disabling routes and goals (for instance according to the game’s progress); • Weapon scripts: Configure how to use and handle some weapon or item • Bot scripts: Stores a behaviour which can be associated to some bots. • Utils: implement some usefull functions for been called in other scripts.
OMNI-BOT – Map scripts Goal script example: goal_askforhealth.gm • this.GetPriority() • if my health < threshold and I’m alive (me, the bot) then • increase this goal’s priority • get nearest health pack • if no pack near, and my team has medics, request medical support • this.update() • if acquired pack, get pack’s position, aim towards it and try to acquire the pack
OMNI-BOT – Goal scripts Goal script example: bunker.gm • Store the logic of the map (the bots don’t know the goal’s dependencies as well as their importance) • If objective taken → leave the stairs and attack the radio; • If objective returned → leave the radio and attack the stairs; • On map start → start attacking the stairs, forget the radio;
OMNI-BOT – Problems Human waypointing, quite boring. Done manually. Detailed waypoints take time as well as routing them. • Proposed navigational mesh, detailed version of waypoints, but with the problem of the mesh resolution.
OMNI-BOT – Problems • Can’t plan a sequence of intentions; • No objectives negotiation between agents (assigned FCFS); • Objectives are not assigned to the nearest agent; • Human coded intentions’ order and priorities; • Don’t ‘learn’ the best paths (currently and in the past); • Don’t predict (and learn) actions taken by others (cooperation and synchronization); • …
OMNI-BOT – Reference http://www.omni-bot.com/wiki/index.php?title=Main_Page http://en.wikipedia.org/wiki/Wolfenstein:_Enemy_Territory http://www.omni-bot.de http://www.gamasutra.com/gdc2005/features/20050311/isla_01.shtml
OMNI-BOT – Questions Tuesday, 16 December 2008