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.

Slides:



Advertisements
Similar presentations
Finite State Machines. Finite State Machines (FSMs) An abstract machine that can exist in one of several different and predefined states Defines a set.
Advertisements

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
TOPIC : Finite State Machine(FSM) and Flow Tables UNIT 1 : Modeling Module 1.4 : Modeling Sequential circuits.
Michael Zyda Finite State Machines Michael Zyda
ECE 353 Computer Systems Lab II VHDL AND LABORATORY TOOLS TUTORIAL Professors Maciej Ciesielski & T. Baird Soules.
INTRODUCTION COMPUTATIONAL MODELS. 2 What is Computer Science Sciences deal with building and studying models of real world objects /systems. What is.
Multimedia Authoring Tools Jon Ivins DMU. Essence of Multimedia… n Combination and integration of different media elements for presentation via a unified.
Chapter 3.2 C++, Java, and Scripting Languages “The major programming languages used in game development.”
ISBN Chapter 1 Preliminaries. Copyright © 2004 Pearson Addison-Wesley. All rights reserved.1-2 Chapter 1 Topics Motivation Programming Domains.
ISBN Lecture 01 Preliminaries. Copyright © 2004 Pearson Addison-Wesley. All rights reserved.1-2 Lecture 01 Topics Motivation Programming.
ECE 301 – Digital Electronics Introduction to Sequential Logic Circuits (aka. Finite State Machines) and FSM Analysis (Lecture #17)
ECE 331 – Digital Systems Design Introduction to Sequential Logic Circuits (aka. Finite State Machines) and FSM Analysis (Lecture #19)
ISBN Chapter 1 Topics Motivation Programming Domains Language Evaluation Criteria Influences on Language Design Language Categories Language.
Reminder Next class (Tuesday), you should have formed groups and select a topic for presentation among: (1)Real-Time Strategy games (Luis Villegas, Dulmovits,
- Chaitanya Krishna Pappala Enterprise Architect- a tool for Business process modelling.
02/06/05 “Investigating a Finite–State Machine Notation for Discrete–Event Systems” Nikolay Stoimenov.
Java Programming, 2E Introductory Concepts and Techniques Chapter 1 An Introduction to Java and Program Design.
Chapter 11-Multimedia Authoring Tools. Overview Introduction to multimedia authoring tools. Types of authoring tools. Cross-platform authoring notes.
Architecture Of ASP.NET. What is ASP?  Server-side scripting technology.  Files containing HTML and scripting code.  Access via HTTP requests.  Scripting.
Rosen 5th ed., ch. 11 Ref: Wikipedia
CSC141 Introduction to Computer Programming
Parser-Driven Games Tool programming © Allan C. Milne Abertay University v
Finite State Machines, cont. Chad Hogg Sections 5.3 & 5.4 of AI Game Programming Wisdom 2.
Automata Based Programming Margarita Spitšakova Institute of Cybernetics at Tallinn University of Technology
Introduction to Java August 14, 2008 Mrs. C. Furman.
Copyright © 2007 Addison-Wesley. All rights reserved.1-1 Reasons for Studying Concepts of Programming Languages Increased ability to express ideas Improved.
FLUKA GUI Status FLUKA Meeting CERN, 10/7/2006.
Software Engineering. Software Engineering is… Design Coding Testing Debugging Documentation Maintenance …of new software.
IMGD 1001: Programming Practices; Artificial Intelligence.
Software Engineering Design & UML.
Application of AI techniques for Computer Games BSc Computer Games Programming, 2006 Julien Delezenne GAMES ARTIFICIAL INTELLIGENCE.
The basics of the programming process The development of programming languages to improve software development Programming languages that the average user.
Artificial Intelligence for Games Finite State Machines
Computational theory techniques in interactive video games.
Core Java Introduction Byju Veedu Ness Technologies httpdownload.oracle.com/javase/tutorial/getStarted/intro/definition.html.
6.5 Implementing a State Machine Language. State Machine in game AI The most used software pattern Simple to program Easy to comprehend Easy to debug.
1 Game System. 2 Control system Control system User input User input Mouse or keyboard Mouse or keyboard Keyboard layout Keyboard layout Camera control.
Introduction to Interactive Media Interactive Media Tools: Authoring Applications.
Computer Science Faculty School of Software Engineering C INTERPRETER AND DEBUGGER (ISO/IEC 9899:2011) Developer: student of 203SE group: Lukyanov Dmitry.
 Programming - the process of creating computer programs.
Getting Started with.NET Getting Started with.NET/Lesson 1/Slide 1 of 31 Objectives In this lesson, you will learn to: *Identify the components of the.NET.
Dr Nick Mitchell (Room CM 224)
Digital System Design using VHDL
CIS 375—Web App Dev II ASP.NET 1 Getting Started.
The Development Process Compilation. Compilation - Dr. Craig A. Struble 2 Programming Process Problem Solving Phase We will spend significant time on.
Class Diagrams. Terms and Concepts A class diagram is a diagram that shows a set of classes, interfaces, and collaborations and their relationships.
Andrey Karaulov, Alexander Strabykin Institute for System Programming Russian Academy of Sciences SYRCoSE: Spring Young Researchers Colloquium on Software.
Chapter – 8 Software Tools.
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 Logical and Artificial Intelligence in Games Lecture 3a.
Application architectures Advisor : Dr. Moneer Al_Mekhlafi By : Ahmed AbdAllah Al_Homaidi.
Automata-Based Programming
Collision Theory and Logic
Advanced Computer Systems
1.3 Finite State Machines.
Collision Theory and Logic
SysML v2 Formalism: Requirements & Benefits
Microprocessor and Assembly Language
Enemy and Friendly AIs Richard Gesick.
1.1 Reasons to study concepts of PLs
Finite State Machines Computer theory covers several types of abstract machines, including Finite State Machines.
Princess Nourah bint Abdulrahman University
Finite State Machines in Games
Programming Languages 2nd edition Tucker and Noonan
Dynamic Modeling Lecture # 37.
CS 1111 Introduction to Programming Spring 2019
IMGD 1001: Programming Practices; Artificial Intelligence
Introduction to Computer Science
Presentation transcript:

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 used Game AI technology –Simple –Efficient –Easily extensible –Powerful enough to handle a wide variety of situations Theory (Simplified) Theory (Simplified) –A set states, S –An input vocabulary, I –Transition function, T(s, i) »Map a state s and an input i to another state 2 Introduction (1/2)

Practical use Practical use –State »Behavior –Transition »Across states »Conditions –It’s all about driving behavior Flow-chart Diagram Flow-chart Diagram –UML (universe modeling language) state chart »Arrow Transition Transition »Rectangle State State 3 Introduction (2/2)

4 An Example of FSM wander Attack Rot seeEnemy Win Dead

Character AI Character AI “Decision-Action” Model “Decision-Action” Model Behavior Behavior –Mental state Transition Transition –Players’ action –The other characters’ actions –Some features in the game world 5 FSM for Games

Code-based FSM Code-based FSM –Simple Code One Up »Straightforward »Most common –Macro-assisted FSM language Data-Driven FSM Data-Driven FSM –FSM Script Language 6 Implement FSM

7 Coding an FSM – Code Example 1 void RunLogic(int &state) { switch(state) switch(state) { case 0: // Wander case 0: // Wander Wander(); Wander(); if (SeeEnemy()) state = 1; if (SeeEnemy()) state = 1; if (Dead()) state = 2; if (Dead()) state = 2; break; break; case 1: // Attack case 1: // Attack Attack(); Attack(); if (Win()) state = 0; if (Win()) state = 0; if (Dead()) state = 2; if (Dead()) state = 2; break; break; case 2: // Dead case 2: // Dead SlowlyRot(); SlowlyRot(); break; break; }} What is the problem with the above code ?

8 Coding an FSM – Code Example 2 void RunLogic(FSM *fsm) { // Do action based on the state and determine next input // Do action based on the state and determine next input input = STATE_NULL; input = STATE_NULL; switch(fsm->GetStateID()) switch(fsm->GetStateID()) { case STATE_WANDER: // Wander case STATE_WANDER: // Wander Wander(); Wander(); if (SeeEnemy()) input = STATE_SEE_ENEMY; if (SeeEnemy()) input = STATE_SEE_ENEMY; if (Dead()) input = STATE_DEAD; if (Dead()) input = STATE_DEAD; break; break; case STATE_ATTACK: // attack case STATE_ATTACK: // attack Attack(); Attack(); if (Win()) input = STATE_WANDER; if (Win()) input = STATE_WANDER; if (Dead()) input = STATE_DEAD; if (Dead()) input = STATE_DEAD; break; break; case STATE_DEAD: // Dead case STATE_DEAD: // Dead SlowlyRot(); SlowlyRot(); break; break; } // DO state transition based on computed input // DO state transition based on computed input fsm->StateTransition(input); fsm->StateTransition(input);}

Mealy Machine Mealy Machine –A Mealy machine is an FSM whose actions are performed on transitions Moore Machine Moore Machine –A Moore machine’s actions reside in states –More intuitive for game developers 9 Mealy & Moore Machines

Coding a state machine directly causes lack of structure Coding a state machine directly causes lack of structure –Going complex when FSM at their largest Use Macro Use Macro Beneficial Properties Beneficial Properties –Structure –Readability –Debugging Simplicity Simplicity 10 FSM Language Use Macros

11 FSM Language Use Macros – An Example #define BeginStateMachine … #define State(a) … … bool MyStateMachine::States(StateMachineEvent event, int state) int state){ BeginStateMachine BeginStateMachine State(STATE_WANDER) State(STATE_WANDER) OnUpdate OnUpdate Wander(); Wander(); if (SeeEnemy()) SetState(STATE_ATTACK); if (SeeEnemy()) SetState(STATE_ATTACK); if (Dead()) SetState(STATE_DEAD); if (Dead()) SetState(STATE_DEAD); State(STATE_ATTACK) State(STATE_ATTACK) OnUpdate OnUpdate Attack(); Attack(); SetState(STATE_WANDER); SetState(STATE_WANDER); if (Dead()) SetState(STATE_DEAD); if (Dead()) SetState(STATE_DEAD); State(STATE_DEAD); State(STATE_DEAD); OnUpdate OnUpdate RotSlowly(); RotSlowly(); EndStateMachine EndStateMachine}

Scripting language Scripting language –Text-based script file –Transformed into »C++ Integrated into source code Integrated into source code »Bytecode Interpreted by the game Interpreted by the game Authoring Authoring –Compiler –AI editing tool Game Game –FSM script engine –FSM interface 12 Data-Driven FSM

13 Data-Driven FSM Diagram Authoring FSMs bytecode Compiler AI Editing Tool Condition & Action Vocabulary Games FSM Script Engine FSM Interface Condition & Action Code Game Engine Artist, Designers, & Developers

Pure text Pure text –Syntax ? Visual graph with text Visual graph with text Used by designers, artists, or developers Used by designers, artists, or developers –Non-programmers Conditions & action vocabulary Conditions & action vocabulary –SeeEnemy –CloseToEnemy –Attack –…–…–…–… 14 AI Editing Tool for FSM

Facilitating the binding between vocabulary and the game world Facilitating the binding between vocabulary and the game world Gluing layers that Implement the condition & action vocabulary in the game world Gluing layers that Implement the condition & action vocabulary in the game world Native conditions Native conditions –SeeEnemy(), CloseToEnemy() Action library Action library –Attack(…) –Evade(…) –Flee(…) –Wander(…) 15 FSM Interface

Accelerated productivity Accelerated productivity Contributions from artists & designers Contributions from artists & designers Ease of Use Ease of Use Extensibility Extensibility 16 FSM Script Language Benefits