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.

Slides:



Advertisements
Similar presentations
Chapter 09 AI techniques in different game genres (Puzzle/Card/Shooting)
Advertisements

7.1. O SCARS & A RTIFICIAL I NTELLIGENCE Interim awards and introduction to game AI.
Finite State Machines in Games
Lecture 8: Three-Level Architectures CS 344R: Robotics Benjamin Kuipers.
Artificial Intelligence for Games Patrick Olivier & John Shearer
Michael Zyda Finite State Machines Michael Zyda
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.
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.
RED DEAD REVOLVER Artificial Intelligence Critique By Mitchell C. Dodes CIS 588.
10/30/2001CS 638, Fall 2001 Today AI –Overview –State Machines.
And Just Games etc.. EVOLUTION OF COMPUTER GAMES PongOdyssey Beginning of the use of microprocessors ATARI VCS system bit.
Artificial Intelligence in Game Design Probabilistic Finite State Machines.
Artificial Intelligence CSE 191A: Seminar on Video Game Programming Lecture 7: Artificial Intelligence UCSD, Spring, 2003 Instructor: Steve Rotenberg.
Introduction to Game AI CS 395 Game Design Spring 2003.
GATE Common AI Architectures (GATE-561) Dr.Çağatay ÜNDEĞER Instructor Middle East Technical University, GameTechnologies Bilkent University, Computer.
11/1/2001CS 638, Fall 2001 Today AI –Decision trees –Rule-based systems.
Artificial Intelligence in Game Design Event and Sense Management.
Object-Oriented Software Engineering Practical Software Development using UML and Java Chapter 8: Modelling Interactions and Behaviour.
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.
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.
Winrunner Usage - Best Practices S.A.Christopher.
Artificial Intelligence in Game Design Behavior Trees.
Artificial Intelligence in Game Design
University of Texas at Austin CS 378 – Game Technology Don Fussell CS 378: Computer Game Technology AI – Decision Trees and Rule Systems Spring 2012.
Motion Planning in Games Mark Overmars Utrecht University.
CS-378: Game Technology Lecture #2.2: Clipping and Hidden Surfaces Prof. Okan Arikan University of Texas, Austin Thanks to James O’Brien, Steve Chenney,
Jumping, Climbing, and Tactical Reasoning Section 2.5 Tom Schaible CSE 497 – AI & Game Programming.
More on Logic Today we look at the for loop and then put all of this together to look at some more complex forms of logic that a program will need The.
CS-378: Game Technology Lecture #13: Animation Prof. Okan Arikan University of Texas, Austin Thanks to James O’Brien, Steve Chenney, Zoran Popovic, Jessica.
“The perfect project plan is possible if one first documents a list of all the unknowns.” Bill Langley.
Games Development Game Architecture: Entities CO2301 Games Development 1 Week 22.
Artificial Intelligence for Games Finite State Machines
Basic Memory Management 1. Readings r Silbershatz et al: chapters
Some Thoughts to Consider 8 How difficult is it to get a group of people, or a group of companies, or a group of nations to agree on a particular ontology?
CS-378: Game Technology Lecture #15.5: Physically Based Simulation Prof. Okan Arikan University of Texas, Austin Thanks to James O’Brien, Steve Chenney,
Sega 500 Scripted events and Sequences Jeff “Ezeikeil” Giles
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.
Finite State Machines using Alice Stephen Cano CIS 4914 Senior Project Wednesday December 5th.
Finite State Machines GAM 376 Robin Burke Winter 2006.
M1G Introduction to Programming 2 2. Creating Classes: Game and Player.
07/22/02 Scalable Dynamics Stephen Chenney University of Wisconsin – Madison
Artificial Intelligence in Game Design Lecture 20: Hill Climbing and N-Grams.
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.
Lecture 4 Page 1 CS 111 Summer 2013 Scheduling CS 111 Operating Systems Peter Reiher.
Learning Procedural Knowledge through Observation -Michael van Lent, John E. Laird – 인터넷 기술 전공 022ITI02 성유진.
Game Maker Tutorials Introduction Clickball IntroductionClickball Where is it? Shooting Where is it?Shooting.
The Game Development Process: Artificial Intelligence.
Finite State Machines GAM 376 Robin Burke Winter 2008.
Bbm421 – Computer Games Technology
Representing Structure and Behavior
Lesson Objectives Aims Key Words Paging, Segmentation, Virtual Memory
Decision Making: Decision Tree & State Machines Session 07
CS 134 Video Game “AI”.
Game Architecture Rabin is a good overview of everything to do with Games A lot of these slides come from the 1st edition CS 4455.
Main issues: • What do we want to build • How do we write this down
Artificial Intelligence and Computer Games
Lecture 2 Introduction to Programming
CSCI1600: Embedded and Real Time Software
Interaction with artificial intelligence in games
Games Development Game Architecture: Entities
CSCI1600: Embedded and Real Time Software
Presentation transcript:

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 V

Today Homework 2 is due on Thursday Signup for Project meetings Introduction to AI Half Life 2

What is AI? AI is the control of every non-human entity in a game The other cars in a car game The opponents and monsters in a shooter Your units, your enemy’s units and your enemy in a RTS game But, typically does not refer to passive things that just react to the player and never initiate action That’s physics or game logic For example, the blocks in Tetris are not AI, nor is a flag blowing in the wind It’s a somewhat arbitrary distinction

AI in the Game Loop AI is updated as part of the game loop, after user input, and before rendering There are issues here: Which AI goes first? Does the AI run on every frame? Is the AI synchronized?

AI and Animation AI determines what to do and the animation does it AI drives animation, deciding what action the animation system should be animating Scenario 1: The AI issues orders like “move from A to B”, and it’s up to the animation system to do the rest Scenario 2: The AI controls everything down to the animation clip to play Which scenario is best depends on the nature of the AI system and the nature of the animation system Is the animation system based on move trees (motion capture), or physics, or something else Does the AI look after collision avoidance? Does it do detailed planning?

AI Module AI Update Step The sensing phase determines the state of the world May be very simple - state changes all come by message Or complex - figure out what is visible, where your team is, etc The thinking phase decides what to do given the world The core of AI The acting phase tells the animation what to do Generally not interesting Game Engine Sensing Thinking Acting

AI by Polling The AI gets called at a fixed rate Senses: It looks to see what has changed in the world. For instance: Queries what it can see Checks to see if its animation has finished running And then acts on it Why is this generally inefficient?

Event Driven AI Event driven AI does everything in response to events in the world Events sent by message (basically, a function gets called when a message arrives, just like a user interface) Example messages: A certain amount of time has passed, so update yourself You have heard a sound Someone has entered your field of view Note that messages can completely replace sensing, but typically do not. Why not? Real system are a mix - something changes, so you do some sensing

AI Techniques in Games Basic problem: Given the state of the world, what should I do? A wide range of solutions in games: Finite state machines, Decision trees, Rule based systems, Neural networks, Fuzzy logic A wider range of solutions in the academic world: Complex planning systems, logic programming, genetic algorithms, Bayes-nets Typically, too slow for games

Goals of Game AI Several goals: Goal driven - the AI decides what it should do, and then figures out how to do it Reactive - the AI responds immediately to changes in the world Knowledge intensive - the AI knows a lot about the world and how it behaves, and embodies knowledge in its own behavior Characteristic - Embodies a believable, consistent character Fast and easy development Low CPU and memory usage These conflict in almost every way

Two Measures of Complexity Complexity of Execution How fast does it run as more knowledge is added? How much memory is required as more knowledge is added? Determines the run-time cost of the AI Complexity of Specification How hard is it to write the code? As more “knowledge” is added, how much more code needs to be added? Determines the development cost, and risk

Expressiveness What behaviors can easily be defined, or defined at all? Propositional logic: Statements about specific objects in the world – no variables Jim is in room7, Jim has the rocket launcher, the rocket launcher does splash damage Go to room8 if you are in room7 through door14 Predicate Logic: Allows general statement – using variables All rooms have doors All splash damage weapons can be used around corners All rocket launchers do splash damage Go to a room connected to the current room

General References As recommended by John Laird, academic game AI leader and source of many of these slides AI Russell and Norvig: Artificial Intelligence: A Modern Approach, Prentice Hall, 1995 Nilsson, Artificial Intelligence: A New Synthesis, Morgan Kaufmann, 1998 AI and Computer Games LaMothe: Tricks of the Windows Game Programming Gurus, SAMS, 1999, Chapter 12, pp

Finite State Machines (FSMs) A set of states that the agent can be in Connected by transitions that are triggered by a change in the world Normally represented as a directed graph, with the edges labeled with the transition event Ubiquitous in computer game AI Idle Chase Enemy Attack Enemy visible Enemy lost Enemy in range Enemy out of range Enemy lost

Quake Bot Example Types of behavior to capture: Wander randomly if don’t see or hear an enemy When see enemy, attack When hear an enemy, chase enemy When die, respawn When health is low and see an enemy, retreat Extensions: When see power-ups during wandering, collect them Borrowed from John Laird and Mike van Lent’s GDC tutorial

Example FSM States: E: enemy in sight S: sound audible D: dead 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 Wander ~E,~S,~D ~E D Attack E,~D ~E E E D ~S Chase S,~E,~D E S S D

Example FSM Problem States: E: enemy in sight S: sound audible D: dead Events: E: see an enemy S: hear a sound D: die Spawn D Wander ~E,~S,~D ~E D Attack E,~D ~E E E D ~S Chase S,~E,~D E S S D Problem: Can’t go directly from attack to chase. Why not?

Better Example FSM States: E: enemy in sight S: sound audible D: dead Events: E: see an enemy S: hear a sound D: die Extra state to recall whether or not heard a sound while attacking Spawn D Wander ~E,~S,~D ~E D Attack E,~S,~D ~E E E D ~S Chase S,~E,~D S S D E Attack-S E,S,~D ~E ~S S D

Example FSM with Retreat Spawn D (-E,-S,-L) Wander -E,-D,-S,-L E -S Attack-E E,-D,-S,-L E Chase -E,-D,S,-L S D S D D Retreat-E E,-D,-S,L L -E Retreat-S -E,-D,S,L Wander-L -E,-D,-S,L Retreat-ES E,-D,S,L Attack-ES E,-D,S,-L E E -E -L S -S L -E E L -L L D States: –E: enemy in sight –S: sound audible –D: dead –L: Low health Worst case: Each extra state variable can add n extra states n = number of existing states

Hierarchical FSMs What if there is no simple action for a state? Expand a state into its own FSM, which explains what to do if in that state Some events move you around the same level in the hierarchy, some move you up a level When entering a state, have to choose a state for it’s child in the hierarchy Set a default, and always go to that Or, random choice Depends on the nature of the behavior

Hierarchical FSM Example Note: This is not a complete FSM All links between top level states still exist Need more states for wander Start Turn Right Go-through Door Pick-up Powerup Wander Attack Chase Spawn ~E E ~S S D ~E

Non-Deterministic Hierarchical FSM (Markov Model) Adds variety to actions Have multiple transitions for the same event Label each with a probability that it will be taken Randomly choose a transition at run-time Markov Model: New state only depends on the previous state Attack Start Approach Aim & Jump & Shoot Aim & Slide Left & Shoot Aim & Slide Right & Shoot

Efficient Implementation Create a state x event table Next state = table[current state, event] event state

FSM Advantages Very fast – one array access Expressive enough for simple behaviors or characters that are intended to be “dumb” Can be compiled into compact data structure Dynamic memory: current state Static memory: state diagram – array implementation Can create tools so non-programmer can build behavior Non-deterministic FSM can make behavior unpredictable

FSM Disadvantages Number of states can grow very fast Exponentially with number of events: s=2 e Number of arcs can grow even faster: a=s 2 Propositional representation Difficult to put in “pick up the better powerup”, “attack the closest enemy” Expensive to count: Wait until the third time I see enemy, then attack Need extra events: First time seen, second time seen, and extra states to take care of counting

References Web references: _into_games.htm csr.uvic.ca/~mmania/machines/intro.htm /doc/design_principles/fsm.html Game Programming Gems Sections 3.0 & 3.1 It’s very very detailed, but also some cute programming