ai in games roger crawfis/eric fosler-lussier cse 786 game design

14
AI in games AI in games Roger Crawfis/Eric Roger Crawfis/Eric Fosler-Lussier Fosler-Lussier CSE 786 Game Design CSE 786 Game Design

Upload: phillip-underwood

Post on 02-Jan-2016

219 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: AI in games Roger Crawfis/Eric Fosler-Lussier CSE 786 Game Design

AI in gamesAI in games

Roger Crawfis/Eric Fosler-Roger Crawfis/Eric Fosler-LussierLussier

CSE 786 Game DesignCSE 786 Game Design

Page 2: AI in games Roger Crawfis/Eric Fosler-Lussier CSE 786 Game Design

AI vs. AI for gamesAI vs. AI for games AI for games poses a number of unique AI for games poses a number of unique

design challengesdesign challenges Traditional AI:Traditional AI:

Made to handle unseen inputs, large state spaceMade to handle unseen inputs, large state space Too many options possible to compute an exact Too many options possible to compute an exact

optimal solution optimal solution Engineering criteria: best possible performanceEngineering criteria: best possible performance

Game AI:Game AI: The game world is known, though it can still be The game world is known, though it can still be

largelarge In a known world, optimal solutions can be In a known world, optimal solutions can be

precomputedprecomputed Entertainment criteria: smart enough to pose a Entertainment criteria: smart enough to pose a

challenge, but not smart enough to be challenge, but not smart enough to be undefeatibleundefeatible

Page 3: AI in games Roger Crawfis/Eric Fosler-Lussier CSE 786 Game Design

Injecting AI into a GameInjecting AI into a Game Friend: Friend:

autonomous, intelligent NPC helpmatesautonomous, intelligent NPC helpmates Configurable (scripted) behaviors: different Configurable (scripted) behaviors: different

characters solve a problem in different wayscharacters solve a problem in different ways Player may trade places with NPC: automationPlayer may trade places with NPC: automation

Foe:Foe: Opponents get better with timeOpponents get better with time Opponents are less predictable because the Opponents are less predictable because the

individuals’ behavior is not uniformindividuals’ behavior is not uniform Scene ClutterScene Clutter

Provides a richness to your environment.Provides a richness to your environment. Animals grazing, birds flying, people milling Animals grazing, birds flying, people milling

about, automobiles driving, etc.about, automobiles driving, etc.

Page 4: AI in games Roger Crawfis/Eric Fosler-Lussier CSE 786 Game Design

Goals for your gamesGoals for your games Prepare you for entertainment and ‘serious’ Prepare you for entertainment and ‘serious’

gamesgames You must implement at least one of these You must implement at least one of these

featuresfeatures Improve over time Improve over time Goal-driven action decompositionGoal-driven action decomposition A* search A* search

for path planning, with varying cost functions for different for path planning, with varying cost functions for different agents (different agents have different heuristics)agents (different agents have different heuristics)

Game tree searchGame tree search Emergent group behavior (flocking or formations)Emergent group behavior (flocking or formations) ““Intelligent” interaction (e.g. speech/language)Intelligent” interaction (e.g. speech/language)

Your game AI must be data-driven, i.e. it must Your game AI must be data-driven, i.e. it must tune itself or otherwise interoperate with an tune itself or otherwise interoperate with an arbitrary map/level loaded at runtimearbitrary map/level loaded at runtime

Page 5: AI in games Roger Crawfis/Eric Fosler-Lussier CSE 786 Game Design

Warning: AI is not an Warning: AI is not an afterthoughtafterthought

AI elements need to be designed in AI elements need to be designed in from the startfrom the start

Configurable/scripted behavior Configurable/scripted behavior Data-driven map/level layoutsData-driven map/level layouts AI isn’t time-consuming to create, if AI isn’t time-consuming to create, if

coded from the startcoded from the start

Page 6: AI in games Roger Crawfis/Eric Fosler-Lussier CSE 786 Game Design

Improving over timeImproving over time

Agent behavior needs to be composed from Agent behavior needs to be composed from small, modular, context-sensitive actionssmall, modular, context-sensitive actions Evade-right if angle >90 and < 180 Evade-right if angle >90 and < 180

Reward good performance/punish badReward good performance/punish bad Each re-spawn can modify control strategyEach re-spawn can modify control strategy See good discussion in Buckland online bookSee good discussion in Buckland online book You can either perform training and freeze You can either perform training and freeze

optimal play, or let the agent adapt to each optimal play, or let the agent adapt to each useruser

Page 7: AI in games Roger Crawfis/Eric Fosler-Lussier CSE 786 Game Design

Improving over timeImproving over time Example from Buckland (online) Ch 10: brainy aliensExample from Buckland (online) Ch 10: brainy aliens Map sensory input to behavior with a hidden layerMap sensory input to behavior with a hidden layer The time it stayed alive is fitness functionThe time it stayed alive is fitness function When alien dies, replace it with an evolved oneWhen alien dies, replace it with an evolved one

Page 8: AI in games Roger Crawfis/Eric Fosler-Lussier CSE 786 Game Design

Goal-driven behaviorGoal-driven behavior

Multiple steps required to achieve a Multiple steps required to achieve a desired effectdesired effect

Useful in Useful in Action-adventure type games -puzzles to solveAction-adventure type games -puzzles to solve RPG - task underlings with a multi-step jobRPG - task underlings with a multi-step job

Good discussion in Buckland PGAIE ch. 9Good discussion in Buckland PGAIE ch. 9 Each ‘goal’ is an instance of a composite classEach ‘goal’ is an instance of a composite class Many different goals can be created with Many different goals can be created with

minimal codingminimal coding

Page 9: AI in games Roger Crawfis/Eric Fosler-Lussier CSE 786 Game Design

Goal-driven agentsGoal-driven agents

Different classes of agents solve Different classes of agents solve problem in different ways, based on problem in different ways, based on their abilitiestheir abilities ““Block door”: Block door”:

Strong trolls move boulders in the wayStrong trolls move boulders in the way Small hobbits shovel sand into the openingSmall hobbits shovel sand into the opening

Each agent’s response to the goal depends Each agent’s response to the goal depends on his abilities, available tools, etc.on his abilities, available tools, etc.

Goal object contains alternative recipesGoal object contains alternative recipes One goal at a time is One goal at a time is activeactive for each agent for each agent

In more complex games, might have goal queue In more complex games, might have goal queue

Page 10: AI in games Roger Crawfis/Eric Fosler-Lussier CSE 786 Game Design

A* path planningA* path planning

Smart path planning/locomotion Smart path planning/locomotion using waypoints/grabpoints built into using waypoints/grabpoints built into the worldthe world

Board/card games like chess/poker Board/card games like chess/poker are impossible to completely search, are impossible to completely search, heuristics are required and search heuristics are required and search cutoffscutoffs

Page 11: AI in games Roger Crawfis/Eric Fosler-Lussier CSE 786 Game Design

flocking/formationflocking/formation Agents have small goals to balance that Agents have small goals to balance that

result in emergent behaviorresult in emergent behavior Flocking: stay close, navigate toward centroid Flocking: stay close, navigate toward centroid

of flock, avoid collisionof flock, avoid collision Results in a ‘crowd’ behavior lookResults in a ‘crowd’ behavior look

Formations: flanking/center/right wing, etc. Formations: flanking/center/right wing, etc. Individuals stay evenly spaced within their groupIndividuals stay evenly spaced within their group Each agent chooses a position within the formationEach agent chooses a position within the formation One agent or central planner selects formationOne agent or central planner selects formation Results in a more disciplined/organized look (Orcs)Results in a more disciplined/organized look (Orcs)

Depends on how organized you want the Depends on how organized you want the agents to appearagents to appear

Page 12: AI in games Roger Crawfis/Eric Fosler-Lussier CSE 786 Game Design

Flocking demosFlocking demos

See Craig Reynold’s Steering See Craig Reynold’s Steering behaviors:behaviors:

http://www.red3d.com/cwr/steer/

Page 13: AI in games Roger Crawfis/Eric Fosler-Lussier CSE 786 Game Design

““Intelligent” interactionIntelligent” interaction

NPCs might communicate state via NPCs might communicate state via languagelanguage E.g. Wii Fit, “All your bases belong to us”E.g. Wii Fit, “All your bases belong to us” Complete job is WAAAAY too hardComplete job is WAAAAY too hard

Input: probably beyond scope of projectInput: probably beyond scope of project Output: May be able to do simple state-Output: May be able to do simple state-

conditional things (mocking, encouragement)conditional things (mocking, encouragement) Scripting languages can be used for rapid Scripting languages can be used for rapid

deploymentdeployment

Page 14: AI in games Roger Crawfis/Eric Fosler-Lussier CSE 786 Game Design

Other AI principles: Other AI principles: observabilityobservability

Don’t let the agents have perfect Don’t let the agents have perfect knowledge: they have to operate in the knowledge: they have to operate in the environment like the players doenvironment like the players do Sense and remember events in their Sense and remember events in their

sensory horizon, memories can have a TTLsensory horizon, memories can have a TTL Perhaps in more advanced levels, they can Perhaps in more advanced levels, they can

communicate with each other about what communicate with each other about what they knowthey know

See article on “adding stupidity to AI”See article on “adding stupidity to AI”