Artificial Intelligence for Games Finite State Machines

Slides:



Advertisements
Similar presentations
The Halo 2 AI In 10 Minutes or Less Damián Isla Bungie Studios
Advertisements

7.1. O SCARS & A RTIFICIAL I NTELLIGENCE Interim awards and introduction to game AI.
8.3. A GENT AND D ECISION M AKING AI Agent driven AI and associated decision making techniques.
ICT2191 Topic 4 State Machines Why State Machines? What is a State Machine? Finite State Automata Finite State Machines Using FSMs Use in Game AI Advantages.
Finite State Machines in Games
Artificial Intelligence for Games Patrick Olivier & John Shearer
Michael Zyda Finite State Machines Michael Zyda
By: Michael Chamberlain. G oal: To create an intelligent “Pacman” character and intelligent monsters who attempt to chase the character.. Character can.
Artificial Intelligence in Game Design Representing NPCs as Finite State Machines.
Administrative This was the last homework for the semester (yay!) First run of games: October 16 nd in class –Short document describing: goal + operational.
Finite State Machine for Games Fall 2012 Ref: Chenney, CS679 lectures AI Game Programming Wisdom 2.
Artificial Intelligence in Game Design Intelligent Decision Making and Decision Trees.
Automated Planning & Computer Games: Perspectives and Applications Hector Munoz-Avila.
Artificial Intelligence in Game Design Introduction to Learning.
Artificial Intelligence in Game Design Hierarchical Finite State Machines.
1 AI for Computer Game Developers Finite state machines Path finding and waypoints A-Star path finding.
Deteministic method (FSM) Dan Witzner Hansen. 2 Last week The objective of the course is to introduce the students to a wide variety of artificial intelligence.
CS-378: Game Technology Lecture #16: AI Prof. Okan Arikan University of Texas, Austin Thanks to James O’Brien, Steve Chenney, Zoran Popovic, Jessica Hodgins.
CS 4730 Game AI CS 4730 – Computer Game Design Some slides courtesy Tiffany Barnes, NCSU.
“Programming” Games Without Programming (sort of) H. Muñoz-Avila Jarret Raim Jonathan Martin.
10/30/2001CS 638, Fall 2001 Today AI –Overview –State Machines.
Artificial Intelligence in Game Design Probabilistic Finite State Machines.
Artificial Intelligence in Game Design Representing NPCs as Finite State Machines.
GATE Common AI Architectures (GATE-561) Dr.Çağatay ÜNDEĞER Instructor Middle East Technical University, GameTechnologies Bilkent University, Computer.
CS603 Communication Mechanisms 14 January Types of Communication Shared Memory Message Passing Stream-oriented Communications Remote Procedure Call.
Artificial Intelligence in Game Design Camera Control.
What is Concurrent Programming? Maram Bani Younes.
Artificial Intelligence in Game Design Event and Sense Management.
Ch.2 Part A: Requirements, State Charts EECE **** Embedded System Design.
Raven Robin Burke GAM 376. Soccer standings Burke, 7 Ingebristen, 6 Buer, 6 Bukk, 6 Krishnaswamy, 4 Lobes, 3 Borys, 2 Rojas, 2 Bieneman, 2.
Artificial Intelligence in Game Design Problems and Goals.
TECHNOLOGY. Computer games have always been driven by technology. For many years it was advances in graphics that changed the way computer games were.
Slides created by: Professor Ian G. Harris Test and Debugging  Controllability and observability are required Controllability Ability to control sources.
Finite State Machine for Games Spring 2005 Ref: Chenney, CS679 lectures AI Game Programming Wisdom 2.
Video Game AI. Classical Games – Focus on optimal players using computationally expensive search techniques Video Game AI – Refers to games such as First.
Artificial Intelligence in Game Design Behavior Trees.
Artificial Intelligence in Game Design
RECAP CSE 348 AI Game Programming Héctor Muñoz-Avila.
1 Game AI Finite State Machine. Finite State Machine (FSM) is the most commonly used Game AI technology Finite State Machine (FSM) is the most commonly.
Artificial Intelligence in Game Design N-Grams and Decision Tree Learning.
Artificial Intelligence in Game Design Complex Steering Behaviors and Combining Behaviors.
Chapter 3 Digital Logic Structures. 3-2 Combinational vs. Sequential Combinational Circuit always gives the same output for a given set of inputs  ex:
CIS 588 AI Evaluation for World of Warcraft Jonathan Schmoll February 14, 2005.
Computational theory techniques in interactive video games.
Intelligent Database Systems Lab 國立雲林科技大學 National Yunlin University of Science and Technology 1 Evolving Reactive NPCs for the Real-Time Simulation Game.
F.E.A.R. Game AI Evaluation by Robert Rak. What is F.E.A.R. ? FEAR is a First Person Shooter game Player takes on the role of an elite strike force team.
SM2220 – Class 06 Finite Automata. SM2220 – Class 06 Topic in theoretical computing. A subset of computation machines. Closely related to formal language.
School of Computer Science & Software Engineering
Dr Nick Mitchell (Room CM 224)
Finite State Machines (FSM) OR Finite State Automation (FSA) - are models of the behaviors of a system or a complex object, with a limited number of defined.
Artificial Intelligence in Game Design Lecture 8: Complex Steering Behaviors and Combining Behaviors.
Game AI Matthew Hsieh Meng Tran. Computer Games Many different genres  Action  Role Playing  Adventure  Strategy  Simulation  Sports  Racing Each.
1 CO Games Development 1 Week 3 Game Agents 2 Gareth Bellaby.
1 CO Games Development 1 Week 4 Finite State Machines + Maths Gareth Bellaby.
Finite State Machines GAM 376 Robin Burke Winter 2006.
1 Game AI Finite State Machine. 2 Finite State Machine (FSM) is the Most Commonly used Game AI Technology Today Finite State Machine (FSM) is the Most.
Finite State Machines GAM 376 Robin Burke Fall 2006.
Finite State Machines Logical and Artificial Intelligence in Games Lecture 3a.
10/23/03CS679 - Fall Copyright Univ. of Wisconsin Last Time Terrain Generation We’re pretty much done with the graphics part of the course.
The Game Development Process: Artificial Intelligence.
Finite State Machines GAM 376 Robin Burke Winter 2008.
CO Games Development 2 Week 22 Trees
Artificial Intelligence and Computer Games
Event driven architectures
Enemy and Friendly AIs Richard Gesick.
Artificial Intelligence in Game Design
CO Games Development 2 Week 19 Extensions to Finite State Machines
Solution Prove by induction the following statement:
Finite State Machines in Games
Interaction with artificial intelligence in games
Presentation transcript:

Artificial Intelligence for Games Finite State Machines Patrick Olivier p.l.olivier@ncl.ac.uk

“Intelligent” Behaviours Restrict “behaviour” to “intelligent behaviours” For example: trajectory of a car is not “intelligent”  decision to fight and what to fight  decision to flee and what to flee from  Complex behaviours implement more intelligent opponents define a kind a “personality” for NPCs or opponents formalising behaviours makes gameplay explicit Behaviour of a vehicle in a car simulator is not classed as “intelligent”. Decisions are classed as “intelligent behaviours”. Complex behaviours can be seen as more intelligent opponents: defining a kind of personality. Can create formal models that explicitly model aspects of gameplay (suspense, resolution, sense of achievement, etc.)

Finite state machines: theory Simple theoretical construct: Set of states (S) Input vocabulary (I) Transition function T(s,i) A way of denoting how an object can change its state over time 1 2 3 4 5 b a c d e f g Behaviour model with a finite set of states (including a start state, and a set of accept/end states), transitions between the states based on the input, and (typically) actions to be performed on entry/exit/input or transition. Typically modelled using a state transition diagram, or a state transition table.

Finite state machines: practice Character AI modeled as a sequence of mental states World events can force a state change Easy to grasp, even for non-programmers Input to the FSM continues as long as the game continues Gather Treasure Flee Fight Monster In Sight No Monster Monster Dead Cornered Behaviour model.

Finite state machines: example States Atttack Inspect Spawn Patrol Events E: see an enemy S: hear a sound D: die Action performed On each transition On each update in some states (e.g. attack) Spawn D Inspect ~E Attack E,~D E S Patrol ~S

Pac-man: Blinky (the red ghost) (In depth detail for how the “Chase Player” state actually works) [more of an empirical/procedural scripted solution] 30 year old game, simple AI rules coded in a few lines of assembly that produced relatively complex results – each ghost seemed to have a subtle ‘personality’. Blinky (red): Appears to chase the pac-man. Simply finds the relative position (without considering the direction) and at each junction will turn to reduce whichever is the greater of the horizontal distance or vertical distance between himself and Pac-Man. Pinky (pink): Appears to help ambush you in association with Blinky. Input is four tiles in front of Pac-Man (taking into account both the position and the direction of the Pac-Man). Attempts to home in on this target using the same logic as described for red. Inky (blue): Appears to only attack when Blinky is around. Actually homing in on a target that is at the end of a line segment from Blinky to two spaces ahead of the pac-man, doubled in length. Clyde (orange): Appears to be not very interested in attacking. Actually has a ‘far’ and a ‘near’ mode. When far from pac-man (further than 8 tiles), he uses Blinky’s logic to close in. However, when near to pac-man (within 8 tiles) he instead heads off for his corner of the maze (lower left). (Edible ghosts: Random seed generator called at each junction. If a wall, attempts the remaining directions in turn.)

FSMs: advantages & disadvantages Easy to understand Easy to implement Flexible: suitable for a range of problems Disadvantages: Scalability: can be cumbersome State oscillation State oscillation: state change with actions => exceed threshold for transition (quantized values) => state change with actions => exceed threshold for transition => (repeat) = oscillating states.

FSMs: implementation issues Polling Simple and easy to debug Inefficient since FSM’s are always evaluated Event Driven Model FSM registers which events it is interested in Requires Observer model in engine Multithreaded Each FSM assigned its own thread Requires thread-safe communication Conceptually elegant Difficult to debug Alternatively: Microthreading/co-routines. For example (not FSA but), as Linden Lab’s Second Life executes “LSL” scripts in their modified Mono virtual machine.

Class exercise 10 minutes exercise work in pairs or threes pick a game scenario agree on percepts for the scenario each develop an FSM for a different NPCs aim for interesting interactions: between player and NPCs between NPCs hand in a “final” sheet (with names on it) Percepts = perceived form of some stimuli.

Extensions: Hierarchical FSMs expand a state into its own sub-FSM some events move you around the same level in the hierarchy, some move you up a level when entering a state, choose a sub-state: set a default, and always go to that random choice depends on the nature of the behaviour Better scaling, re-use of logic in different contexts.

Extensions: Hierarchical FSMs Attack Wander ~E Chase E Pick-up Powerup ~S S Start Turn Right D Spawn “Super state” has “generalized transitions” that don’t need to be applied to each of the sub-states. Re-use of sub-states could be allowed. ~E Go-through Door

Extensions: stack-based FSMs Gives the AI a (limited) form of ‘memory’ Switch states, then return to a previous state Permits temporary interruption More realistic behaviour Not all states stack-able Replacement behaviours Place FSM state in a stack Example: Thief 3 – NPC could be performing some action (chatting, patrolling), interrupted to perform search.

Extensions: inertial FSMs Need to address the oscillation problem For example – basketball: LOS=FALSE  stand-state LOS=TRUE  basket-drive-state Introduce inertia to dampen state changes State inertia (e.g. minimum running times) Perceptual inertia (e.g. multiple firings) LOS = Line of sight State oscillation: state change with actions => exceed threshold for transition (quantized values) => state change with actions => exceed threshold for transition => (repeat) = oscillating states.

Other extensions of FSMs… Inter-character concurrent FSM Coordinating multiple characters Intra-character concurrent FSM Coordinating multiple behaviours (in one NPC) Levels of detail (LODs) Analogous to LOD in graphics e.g. crowd simulation Proximal NPCs use fully elaborated FSM Distal characters use fixed paths or worse Inter-character concurrent FSM – coordinates behaviour between characters. Intra-character concurrent FSM – coordinates multiple behaviours within on character.

Nondeterministic FSMs Probabilistic FSMs multiple transitions for same event each transition has probability that it will be taken probabilistically choose a transition at run-time Attack Start Approach Jump & Shoot Aim & Shoot Slide .1 .3 .4 .2 In deterministic finite automaton the next possible state is uniquely determined. However, a nondeterministic finite state machine is a finite state machine where for each pair of state and input symbol there may be several possible next states.

Questions? Behaviour model with a finite set of states start state set of accept/end states transitions between the states (based on the input) actions to be performed on entry/exit/input or transition - Lambda (null) transitions – can remove and collapse states. Representation: state transition diagram state transition table. [Additional: In depth detail for how the “Chase Player” Pac-Man state actually works – as an empirical/procedural scripted solution]