CO2301 Games Development 1 Week 2 Finite State Machines Transitions - PowerPoint PPT Presentation

1 / 19
About This Presentation
Title:

CO2301 Games Development 1 Week 2 Finite State Machines Transitions

Description:

Line represents a transition between states, single-direction only. ... if FSM is piled upon FSM. lots of interconnecting FSMs (feedback) ... – PowerPoint PPT presentation

Number of Views:46
Avg rating:3.0/5.0
Slides: 20
Provided by: gjbel
Category:

less

Transcript and Presenter's Notes

Title: CO2301 Games Development 1 Week 2 Finite State Machines Transitions


1
CO2301 - Games Development 1Week 2Finite State
Machines Transitions
  • Gareth Bellaby

2
  • Finite State Machines

3
Finite State Machines
  • A FSM is a machine which models states,
    transitions between states, and actions.
  • State Transition Diagram.

4
Convention being used
  • Box represents a state.
  • Line represents a transition between states,
    single-direction only.
  • An arrow with a dot at the end indicates the
    start state.
  • A state can just be an start state (nothing leads
    into the state).
  • A state can just be an end state (nothing leads
    from the state).

5
FPS Monster
  • Simple monster that reacts when the player comes
    into range and is in line-of-sight. Note
    different convention.

Attacking
No hit points
Attacks
Idle
Start
Dying
6
FPS enemy
Start
See Enemy
Attack
No Enemy
Wander
Low Health
Flee
Taken from Intro to Game Development
No Enemy
7
UML
  • UML lends itself well to the design of a FSM.

8
Characteristics
  • Two type of machine
  • Actions occur within a state
  • Actions occur during a transition
  • In the games industry the distinctions between
    the two types of FSMs are blurred.
  • It is common to see a FSM in which actions occur
    within a state and in which actions occur during
    a transition.

9
Simple Strategic RTS
Build (middle game)
Resource Level
Start
Numerical Inferiority
Explore (early game)
Numerical Superiority
Attack
10
Thief (approximately...)
Suspicious Sound/Sight
Suspicious Sound/Sight
Minor Sound
Suspicious
Definite Sound/Sight
Timer
Not alert
Definite Sound/Sight
Fully Alerted
Start
Suspicious Sound/Sight
Timer
11
Pac-Man Ghost (simplified)
Power Pill
Hunted
Power Pill
Eaten
Timer
Hunter
Resurrect
Start
Eaten
12
Pac-Man Pac-Man (simplified)
Power Pill
Power Pill
Hunter
Timer
Hunted
Collision
Start
Dying
If lives gt 0
13
Capabilities
  • A game actor may have more than one FSM. One FMS
    could be swapped out and replaced by another.
  • A FSM could cause a cause in another FSM, e.g. a
    guard alerting another guard.
  • Probabilities
  • Randomness
  • Extra information
  • Extra actions

14
Characteristics of FSMs
  • To summarise, FSMs are
  • Flexible
  • Appropriate
  • Comprehensible and straightforward
  • Can become unwieldy especially
  • if FSM is piled upon FSM
  • lots of interconnecting FSMs (feedback)
  • Additions, special cases, etc. undermine the
    structure.

15
  • Transitions

16
Transitions
  • Consider a threshold from one state to another.
  • Imagine a guard in a FPS. All of the following
    could give rise to an activation value
  • Seeing something unusual
  • Hearing something unusual
  • Hearing something specific like a cry
  • Receiving an instruction from another guard
  • Seeing a guard who has been hurt
  • Seeing a guard being hurt

17
Transitions
  • A simple sensory model could be implemented using
    a set of rules, e.g. a set of if... then
    statements. Such a model may work, but it is
    simple.
  • I want to capture something more complex
  • A definite sighting of the player alerts the
    guard, as does a loud noise.
  • A possible sighting of the player or a quiet
    noise just makes the guard suspicious.
  • But... a possible sighting of the player combined
    with a quiet noise alerts the guard.
  • And... repeated quiets noise occurring over a
    short period of time will alert the guard.
  • But... over time a suspicious guard will get less
    suspicious if nothing else happens.

18
Transitions
This is the same method as that used in neural
nets
Sum the activation values.
  • input signals xi
  • weights wi
  • activation level ?xiwi
  • threshold function f

19
Transitions
  • For example, imagine a Thief type game. One input
    could be sight and we have an activation input
    based on how visible the player is.
  • A second input could be sound and we have another
    activation input based on how loud the player is.
  • The two inputs are summed together. If a
    particular threshold is reached then the guard is
    alerted.
  • The important thing to note is that vision or
    sound can cause activation on their own, but the
    combination of the two increases the likelihood
    of activation.
  • Now imagine extending this model using, for
    example, activation combined with degradation
    over time... leads to a sophisticated model.
Write a Comment
User Comments (0)
About PowerShow.com