150 likes | 181 Views
AI in games. Roger Crawfis/Eric Fosler-Lussier CSE 786 Game Design. AI vs. AI for games. AI for games poses a number of unique design challenges Traditional AI: Made to handle unseen inputs, large state space Too many options possible to compute an exact optimal solution
E N D
AI in games Roger Crawfis/Eric Fosler-Lussier CSE 786 Game Design
AI vs. AI for games • AI for games poses a number of unique design challenges • Traditional AI: • Made to handle unseen inputs, large state space • Too many options possible to compute an exact optimal solution • Engineering criteria: best possible performance • Game AI: • The game world is known, though it can still be large • In a known world, optimal solutions can be precomputed • Entertainment criteria: smart enough to pose a challenge, but not smart enough to be undefeatible
Injecting AI into a Game • Friend: • autonomous, intelligent NPC helpmates • Configurable (scripted) behaviors: different characters solve a problem in different ways • Player may trade places with NPC: automation • Foe: • Opponents get better with time • Opponents are less predictable because the individuals’ behavior is not uniform • Scene Clutter • Provides a richness to your environment. • Animals grazing, birds flying, people milling about, automobiles driving, etc.
Goals for your games • Prepare you for entertainment and ‘serious’ games • You must implement at least one of these features • Improve over time • Goal-driven action decomposition • A* search • for path planning, with varying cost functions for different agents (different agents have different heuristics) • Game tree search • Emergent group behavior (flocking or formations) • “Intelligent” interaction (e.g. speech/language) • Your game AI must be data-driven, i.e. it must tune itself or otherwise interoperate with an arbitrary map/level loaded at runtime
Warning: AI is not an afterthought • AI elements need to be designed in from the start • Configurable/scripted behavior • Data-driven map/level layouts • AI isn’t time-consuming to create, if coded from the start
Improving over time • Agent behavior needs to be composed from small, modular, context-sensitive actions • Evade-right if angle >90 and < 180 • Reward good performance/punish bad • Each re-spawn can modify control strategy • See good discussion in Buckland online book • You can either perform training and freeze optimal play, or let the agent adapt to each user
Improving over time • Example from Buckland (online) Ch 10: brainy aliens • Map sensory input to behavior with a hidden layer • The time it stayed alive is fitness function • When alien dies, replace it with an evolved one
Goal-driven behavior • Multiple steps required to achieve a desired effect • Useful in • Action-adventure type games -puzzles to solve • RPG - task underlings with a multi-step job • Good discussion in Buckland PGAIE ch. 9 • Each ‘goal’ is an instance of a composite class • Many different goals can be created with minimal coding
Goal-driven agents • Different classes of agents solve problem in different ways, based on their abilities • “Block door”: • Strong trolls move boulders in the way • Small hobbits shovel sand into the opening • Each agent’s response to the goal depends on his abilities, available tools, etc. • Goal object contains alternative recipes • One goal at a time is active for each agent • In more complex games, might have goal queue
A* path planning • Smart path planning/locomotion using waypoints/grabpoints built into the world • Board/card games like chess/poker are impossible to completely search, heuristics are required and search cutoffs
flocking/formation • Agents have small goals to balance that result in emergent behavior • Flocking: stay close, navigate toward centroid of flock, avoid collision • Results in a ‘crowd’ behavior look • Formations: flanking/center/right wing, etc. • Individuals stay evenly spaced within their group • Each agent chooses a position within the formation • One agent or central planner selects formation • Results in a more disciplined/organized look (Orcs) • Depends on how organized you want the agents to appear
Flocking demos • See Craig Reynold’s Steering behaviors: http://www.red3d.com/cwr/steer/
“Intelligent” interaction • NPCs might communicate state via language • E.g. Wii Fit, “All your bases belong to us” • Complete job is WAAAAY too hard • Input: probably beyond scope of project • Output: May be able to do simple state-conditional things (mocking, encouragement) • Scripting languages can be used for rapid deployment
Other AI principles: observability • Don’t let the agents have perfect knowledge: they have to operate in the environment like the players do • Sense and remember events in their sensory horizon, memories can have a TTL • Perhaps in more advanced levels, they can communicate with each other about what they know • See article on “adding stupidity to AI”