Finite State Machines and Automata - PowerPoint PPT Presentation

1 / 46
About This Presentation
Title:

Finite State Machines and Automata

Description:

... Machine / Automaton ... A finite state machine / automaton is a device, or a model of a ... Finite State Automata. Computational models often used as recognizers ... – PowerPoint PPT presentation

Number of Views:196
Avg rating:3.0/5.0
Slides: 47
Provided by: Mar5334
Category:

less

Transcript and Presenter's Notes

Title: Finite State Machines and Automata


1
Finite State Machines and Automata
  • Marco Loog

2
Finite State Machine / Automaton
  • Model of behavior composed of states,
    transitions, and actions some output
  • Configuration of AI building blocks for agent
    control

3
Overview
  • Finite state machines and automata
  • Mealy and Moore machines
  • Pros and cons
  • Other forms
  • Fuzzy
  • Nondeterministic
  • Probabilistic
  • Hierarchical

4
Before Proceeding...
  • ...what the e does the author mean by things
    like ? and ??

5
Formal Definition
  • A finite state machine / automaton is a device,
    or a model of a device, which has a finite number
    of states it can be in at any given time It can
    operate on input to either make transitions from
    one state to another and / or to cause an output
    or action to take placeIt can only be in one
    state at any moment in time

6
Finite State Automata
7
Finite State Automata
  • Computational models often used as recognizers or
    acceptors
  • Consists of set of states connected by
    transitions
  • Transitions are triggered by matching inputs

8
More Formally...
  • An FSA is a quadruple S,Q,d,F
  • S alphabet
  • consists of possible inputs
  • Q set of states
  • special states initial and accepting states
  • d transition function defined over alphabet
  • determines next state based on current input
  • F accepting states
  • After all input, if such state is active, input
    pattern is recognized as corresponding class

9
Transition Function
  • Start Character End------------------------------
    -------1 a 41 b 32 b 1etc.

10
Transition Function
  • In principle all possible transitions should be
    defined
  • Easier to assume that nothing happens if
    transition not specified

11
FSM vs. FSA
  • FSA do not generate output until terminal state
    reached recognition or acceptation takes place
  • FSM provides output after each input symbol has
    been processed
  • Can be used for modeling states of NPC

12
Mealy Machines
  • FSM
  • Outputs symbols based on each transition
  • Superset of FSA
  • To define them, we need a quintuple S,Q,Z,d,l
    instead of a quadruple S,Q,d,F
  • S, Q, and d are the same as in FSA
  • Z is an output alphabet replacing F
  • l function similar to state transition function
    d, which maps (state,input) pairs to outputs

13
A Mealy Machine
14
Moore Machines
  • Alternative to Mealy machines
  • Instead of output at every transition, states
    determine output
  • I.e., output provided by function l is only based
    on state and not (state,input)
  • As a consequence output remains the same if
    state does not change

15
A Moore Machine
16
The Finite States of the Ghosts
  • For example (hunting,power pill) ? hunted
  • Taken from Designing an Online Computer Game
    ITU, CGII, fall 2002

17
Some Pros
  • Easy to implement, visualize, debug, etc.
  • Theory is well understood which may help... even
    in practice!
  • Seem to work well in games one of the most often
    used techniques

18
Some Cons
  • Can become complex for large machines
  • Limited to certain problems
  • Output is, in a sense, predictable and therefore
    not necessarily suited to create good behavior
  • Scripting vs. emergence

19
One More Con?
  • Quake-style bots consider states run / wander /
    attack
  • So before attacking, stop running?
  • wander
  • run
  • attack

20
Nondeterministic State Machines
  • ... and / or automata
  • ... and some variations
  • Sometimes useful to use a state machine that may
    have more than one possible transition for each
    combination of current state and input

21
Nondeterministic State Machines
  • Sometimes useful to use a state machine that may
    have more than one possible transition for each
    combination of current state and input
  • In NSMs, more than one possible state response
    and output sequence possible
  • Can simplify modeling of NPCs make output less
    predictable / smoother transitions

22
Fuzzy State Machines
  • Extension of FSM based on fuzzy logic
  • A Degree of membership for every state is defined
  • NPC can run while being in attack state
  • Potential problem with conflicting states
  • May be used for smoother state transitions

23
Fuzzy FSA
  • Again based on a quadruple S,Q,d,F
  • ...and now everything may be fuzzy
  • E.g., one can be in several states at the same
    time
  • Typically, one uses the possibilities of fuzzy
    states only indirectly alphabets
  • d has to be adapted accordingly

24
Fuzzy FSM
  • Again based on a quintuple S,Q,Z,d,l
  • Not surprisingly, similar remarks hold as for the
    fuzzy FSA...

25
A Fuzzy FSM
  • N.B. Graph visualizes only current state

26
A Pro and a Con
  • Fuzzy versions of FSA and FSM give more
    flexibility
  • Risk of combinatorial explosion

27
Nondeterministic State Machines Again?
  • Both FSM and fuzzy FSM are fully deterministic?
  • ... in the sense that knowing the state and the
    input, it can be determined what the next state
    should be
  • For nondeterministic machines more than one next
    state may be defined for each situation

28
Nondeterministic FSA and FSM
  • Now d is defined to a be transition relation
    instead of mapping to a single state, i.e., d can
    map to a set of possible next states
  • Basically, such nondeterministic versions of FSA
    and FSM are difficult to work with and it is
    rather unclear how to really benefit from them in
    games...
  • As an additional remark deterministic and
    these nondeterministic models are equivalent in a
    certain sense

29
Probabilistic State Machines
  • So far, all models have in fact been
    deterministic!
  • Sticking to this claim, probabilistic can also be
    considered deterministic... if fuzzy machines are
  • Although there is something more to it...
  • Well delve into the more rigorous Markov models
    in some later lectures

30
Hierarchical State Machines
  • HSMs are one solution to some flaws with normal
    FSMs
  • Exploiting the fact that tasks can often be
    decomposed in increasingly detailed subtasks,
    applicability can be improved
  • Hierarchies of FSMs are created

31
Difficulties with FSM
  • During any attacking or wandering behavior, run
    away if the enemy boss appears
  • When a flash grenade is thrown, enter dodge mode
  • The attack behavior consists of the task of
    finding, following and shooting at the enemy
  • The camping behavior is independent from weapon
    management

32
Difficulties with FSM
  • During any attacking or wandering behavior, run
    away if the enemy boss appears
  • Need or at least possibility to group together
    cluster states for attacking and wandering
  • Resulting state is referred to as a superstate

33
Difficulties with FSM
  • When a flash grenade is thrown, enter dodge mode
  • Possible need to express transition from any
    state
  • Current behavior is overridden so-called general
    transitions

34
Difficulties with FSM
  • The attack behavior consists of the task of
    finding, following and shooting at the enemy
  • Some behaviors in FSM can be defined as a
    combination of simpler states
  • Implies hierarchy, maybe, in the most natural way

35
Difficulties with FSM
  • The camping behavior is independent from weapon
    management
  • Independence of machine parts there may be no
    need to model all of this in one and the same FSM
  • This last difficulty is not dealt with using
    HSMs

36
Hierarchy
  • Set of objects nested on multiple levels
  • Can be represented as a tree

37
Hierarchical State Machines
  • Hierarchy can be seen as nested states or entire
    machines

38
Nested States
  • HSM allows states to be defined within states
    latter are superstates
  • Approach allows abstraction of FSM
  • E.g. transition between two hierarchy levels are
    interpreted as being connected to all nested
    states
  • Cut-down on number of transitions

39
Hierarchy of State Machines
  • Instead of simplifications using superstates,
    hierarchy can be considered a functional
    decomposition
  • Each nested state provides exclusive
    functionality
  • In this, abstraction, refinement, and modularity
    play a role

40
Abstraction
  • During design / implementation, ignore finer
    details zoom out

41
Refinement
  • Gradually increase complexity of model by
    designing more and more detailed states zooming
    in
  • If needed, refine large simple tasks i.e.,
    those modeled by one FSM

42
Modularity
  • Each FSM can be treated as a modular object and
    can be reused in any part of the hierarchy

43
Advantages
  • Modularity reduces the complexity of the design
  • Can be done with graphical tools possibly a con
    as well
  • Greatly advantageous for gradual refinement of
    behaviors

44
Disadvantage
  • Debugging can be difficult in large models but
    HSM still seem best suited for this complexity

45
Next Weeks Topic
  • Intelligent agents
  • The real start of the course?

46
(No Transcript)
Write a Comment
User Comments (0)
About PowerShow.com