Artificial Intelligence for Games Santa Clara University, 2012
Introduction Class 1
Artificial Intelligence for Games What is different Gaming stresses computing resources Graphics Engine Physics Engine Updates at fixed frame rates Need to keep AI simple or use a complicated time allocation scheme AI needs to look good, but not be good Human beings are likely to attribute intelligent behavior to inanimate objects whose functioning they do not understand
Attribution of Intelligence Simple things can look good Pac-Man 1979 Uses a simple state machine for the behavior of ghosts Each of the four ghosts moves in a straight line At a junction, they choose a route With a ghost-dependent likelihood: Go in the direction of the player Based on coordinates, no path finding Take a random route Users attribute intelligence to the ghosts
Attribution of Intelligence The four of them are programmed to set a trap, with Blinky leading the player into an ambush where the other three lie in wait. To give the game some tension, some clever AI was programmed into the game. The ghosts would group up, attack the player, then disperse. Each ghost has its own AI.
Attribution of Intelligence Complex things can look bad Herdy Gerdy 2002 for PS2 "Herdy Gerdy aims high and delivers little, easily placing it on the list of the PS2's worst games. Herdy Gerdy had herding as its concept Movement AI has problems Characters get caught in scenary Collision detection leads animals into areas where they get stuck
Attribution of Intelligence Complex things can look bad Black and White (2001) Successful game where players have to teach pets Possible to teach bad habits that cannot be unlearned Pets are incapable of performing simple tasks
Attribution of Intelligence Simple things can look good Shooter game: Enemy avatars home in on player Randomly make a side step Tester feed-back Appear to be anticipating shoots and save themselves
Attribution of Intelligence Perception Window Most interaction with avatars is for very short time Simple AI can be better Complex AI can be interpreted as stupid Example: Modeling a guard that has to be taken out Guard hears noise, turns away and goes to a corner Appears stupid Guard wants to turn on light Seems a good idea Guard will be shot dead before the player can see that his behavior is reasonably intelligent
Attribution of Intelligence Perception Window Changes in behavior are more obvious to players than behavior itself WoW: Monsters do not change behavior when players start killing them
Restrictions Speed and Memory
Restrictions Speed Limited by processor SIMD architecture MMX by Intel 1996 SSE by Intel (8 128b registers) with SSE extension by AMD (additional 8 128b registers) matched by SSE2 by Intel Uses parallel processing of data stored in large registers Multi-core architectures allow threading Problems of synchronization between cores Graphical Processing Units offload to graphics card
Restrictions Speed Need to manage carefully processing budget between various components during an update cycle Not all AI calculations need to be done in a single cycle
Restrictions Speed Has influence on programming style Virtual functions / polymorphism Indirection
Restrictions Memory Fetching from memory can take more time than recalculating Memory hierarchy Multi-level cache OO needs additional information with interacts with efficient cache OO needs additional information with interacts with efficient cache use Data coherency
Restrictions PC Inconsistent architectures Programming needs to detect feature support and speed and adjust Programming helped by API (e.g. DirectX) Introduction of scalable AI
Restrictions Consoles Seemingly simpler Much development for future (not yet completely defined) versions of the console Technical Requirement Checklist Console manufacturer places minimum standards Fixes frame rates, Allows AI budgets in millisecond precision Tend to over-emphasize graphics Difficult to translate AI to main processing unit
AI Engine
AI Engine Game engines Reusable platform for game types AI engine Example: Lucasarts SCUMM Script Creation Utility for Maniac Mansion 1987 abandoned in 1998 for GrimE
AI Engine World In nterface Execution Management Group AI Strategy Character AI Decision Making Movement Content Creation Scripting Animation Physics
Toolchains Gaming companies use tool chains for easy content creation Steering behavior Is easily parameterized and does not change between characters Use parameterization of characters instead of regenerating code Rule based systems Complicated systems Interface can use a programming like structure to define rules, input, and behavior