Game AI - PowerPoint PPT Presentation

About This Presentation
Title:

Game AI

Description:

Title: PowerPoint Presentation Last modified by: cswingo Created Date: 1/1/1601 12:00:00 AM Document presentation format: (4:3) Other titles – PowerPoint PPT presentation

Number of Views:38
Avg rating:3.0/5.0
Slides: 17
Provided by: peopleCs98
Category:

less

Transcript and Presenter's Notes

Title: Game AI


1
Game AI Finite State Machine
2
Introduction (1/2)
  • 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)
  • A set states, S
  • An input vocabulary, I
  • Transition function, T(s, i)
  • Map a state s and an input i to another state

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

4
An Example of FSM
seeEnemy
wander
Attack
Win
Dead
Rot
5
FSM for Games
  • Character AI
  • Decision-Action Model
  • Behavior
  • Mental state
  • Transition
  • Players action
  • The other characters actions
  • Some features in the game world

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

7
Coding an FSM Code Example 1
void RunLogic(int state) switch(state)
case 0 // Wander Wander()
if (SeeEnemy()) state 1 if
(Dead()) state 2 break case 1
// Attack Attack() if (Win())
state 0 if (Dead()) state 2
break case 2 // Dead
SlowlyRot() 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 input
STATE_NULL switch(fsm-gtGetStateID())
case STATE_WANDER // Wander
Wander() if (SeeEnemy()) input
STATE_SEE_ENEMY if (Dead()) input
STATE_DEAD break case
STATE_ATTACK // attack Attack()
if (Win()) input STATE_WANDER if
(Dead()) input STATE_DEAD break
case STATE_DEAD // Dead SlowlyRot()
break // DO state transition
based on computed input fsm-gtStateTransition(in
put)
9
Mealy Moore Machines
  • Mealy Machine
  • A Mealy machine is an FSM whose actions are
    performed on transitions
  • Moore Machine
  • A Moore machines actions reside in states
  • More intuitive for game developers

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

11
FSM Language Use Macros An Example
define BeginStateMachine define State(a)
bool MyStateMachineStates(StateMachineEvent
event, int state)
BeginStateMachine State(STATE_WANDER)
OnUpdate Wander() if
(SeeEnemy()) SetState(STATE_ATTACK)
if (Dead()) SetState(STATE_DEAD)
State(STATE_ATTACK) OnUpdate
Attack() SetState(STATE_WANDER)
if (Dead()) SetState(STATE_DEAD)
State(STATE_DEAD) OnUpdate
RotSlowly() EndStateMachine
12
Data-Driven FSM
  • Scripting language
  • Text-based script file
  • Transformed into
  • C
  • Integrated into source code
  • Bytecode
  • Interpreted by the game
  • Authoring
  • Compiler
  • AI editing tool
  • Game
  • FSM script engine
  • FSM interface

13
Data-Driven FSM Diagram
Authoring
Games
FSMs
bytecode
FSM Script Engine
Compiler
Artist, Designers, Developers
AI Editing Tool
FSM Interface
Condition Action Code
Game Engine
Condition Action Vocabulary
14
AI Editing Tool for FSM
  • Pure text
  • Syntax ?
  • Visual graph with text
  • Used by designers, artists, or developers
  • Non-programmers
  • Conditions action vocabulary
  • SeeEnemy
  • CloseToEnemy
  • Attack

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

16
FSM Script Language Benefits
  • Accelerated productivity
  • Contributions from artists designers
  • Ease of Use
  • Extensibility
Write a Comment
User Comments (0)
About PowerShow.com