CO1301 Games Concepts Week 16 Finite State Machines - PowerPoint PPT Presentation

1 / 32
About This Presentation
Title:

CO1301 Games Concepts Week 16 Finite State Machines

Description:

Father of computer science. ... Instrumental in the British efforts to decrypt the Engima device. ... (1936), Proceedings of the London Mathematical Society. ... – PowerPoint PPT presentation

Number of Views:51
Avg rating:3.0/5.0
Slides: 33
Provided by: gjbel
Category:

less

Transcript and Presenter's Notes

Title: CO1301 Games Concepts Week 16 Finite State Machines


1
CO1301 - Games ConceptsWeek 16Finite State
Machines
  • Gareth Bellaby

2
References
  • Rabin, Introduction to Game Development, chapter
    5.3 discusses Finite State Machines in the
    context of AI.

3
Topics
  • States
  • Finite State Machines
  • Alan Turing and Turing Machines

4
States
  • Assignment 2 used the idea of states.
  • Having had some practical experience of working
    with states I want to look at some of the theory.
  • States are a commonly used approach in computing.
  • The diagrams I provided at the end of the
    assignment are state transition diagrams.

5
States in the Assignment
  • 1 Start of the game. Transition is "Distance to
    NPC".
  • 2 Quest. Transition is "Distance to NPC".
  • 3 Combat. Transition is " Monster defeated ".
  • 4 Ring obtained. Transition is "Distance to NPC".
  • 5 Quest Completed.

6
States
7
Usefulness of States
  • States help us express complex behaviour or
    activity.
  • Notice the complexity of what has been expressed.
    For example
  • Dialogue is triggered when the player gets the
    quest.
  • The dialogue is automatically triggered only the
    once.
  • The treasure chest can only be opened after the
    player-character has visited the NPC.

8
State Machines
  • This is called a "state machine".
  • A state is a unique set of properties.
  • Particular instructions which be executed in
    response to particular input.
  • State.
  • Input
  • Response.
  • In combination they form a unique configuation,
    this particular state with this particular input
    will lead to that particular outcome.

9
Why are states used?
  • States describe the game extremely well.
  • You were able to understand this aspect of the
    game mechanics.
  • State Machines are flexible but also extremely
    powerful.
  • A good way to implement the mechanics of a game
    (and other types of software).

10
Why are states used?
  • Aesthetically pleasing.
  • The player experiences smooth gameplay.
  • Unobtrusive. Typically a player will not perceive
    the existence of the state machine. Even if it is
    the case that they do, state machines are
    accepted approach.
  • Also used extensively in AI. We'll do look at
    this again next year.
  • Can provide strong signals to the player, i.e.
    what has happened, what to do next, etc.

11
States
  • A program will have many different state
    machines. For example, consider the assignment
    scenario. We have
  • The state that the monster is in.
  • The state that the treasure chest is in.
  • Each of these things can be considered an object
    (or entity) within the program. This approach
    allows us to easily describe (and therefore
    implement) the life cycle of an object.

12
States
  • For example
  • Monster is created.
  • In an idle state.
  • In a fighting state.
  • Monster is destroyed.
  • This insight leads on to Unified Modelling
    Language - UML. A design method used for Object
    Oriented Programming.

13
States
  • States are the basis of programming languages
    such as C. The program is in a particular
    state. An instruction changes the state of the
    program.
  • With a language such as C computation is
    therefore described as states and instructions
    which change states.
  • I have used the phrase "State Machines".
  • Preferred terminology is "Finite State Machines"
    (FSMs)
  • A state machine with a finite number of states.

14
  • Finite State Machines

15
States
  • Checking the current state of the game
  • A FSM is a machine which models states,
    transitions between states and actions.

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

Attacking
No hit points
Attacks
Idle
Start
Dying
17
Pac-Man Ghost (simplified)
Power Pill
Hunted
Power Pill
Eaten
Timer
Hunter
Resurrect
Start
Eaten
18
Pac-Man Pac-Man (simplified)
Power Pill
Power Pill
Hunter
Timer
Hunted
Collision
Start
Dying
If lives gt 0
19
  • Alan Turing and Turing Machines

20
Alan Turing
  • English mathematician.
  • 1912- 1954.
  • Father of computer science. If any single
    individual can be said to have invented the
    computer I think that person is Turing.
  • During Second World War worked at Bletchley Park,
    the location of Britain's codebreaking centre.
    Instrumental in the British efforts to decrypt
    the Engima device.
  • "On computable numbers, with an application to
    the Entscheidungsproblem", (1936), Proceedings of
    the London Mathematical Society.
  • "Computing Machinery and Intelligence", (1950).
    Computing machinery and intelligence, Mind.

21
Alan Turing
  • Attempting to clarify the foundations of
    mathematics.
  • 1936 Turning defined a class of abstract
    machines now called Turing Machines.
  • Wanted to make precise what is meant by a
    calculation (or an effectively computable
    function).

22
Turing's Approach
  • The approach taken by Turing was to consider
    computation as performed by a human and, by
    dismissing the extraneous and superfluous
    elements, to arrive at a description of the
    fundamental steps of computation.

23
Turing Machine (1)
  • TM is a universal algorithm device.
  • Any calculation defined recursively by algorithm
    can be performed by TM.
  • Any set defined by a recursive definition can be
    defined by a TM.

24
Turing Machine (2)
  • A finite alphabet of input and output symbols.
  • A tape divided into a linear sequence of boxes.
    Each box contains one symbol. Tape can move in
    both directions.
  • A tape head that can read from, and then write
    to, one box at a time.

25
Turing Machine (3)
  • A control or processing unit. The unit can assume
    one a finite number of states (finite state
    machine)
  • A program rules or instructions which define the
    action of the machine when in a particular state
    reading a particular character. The permitted
    actions are to change state (or stay in the same
    state), write a particular symbol (could be the
    same the original symbol).

26
Turing Machine (4)

Tape
Tape Head
Processor
27
Turing Machine (5)
  • Imagine a TM with the following program
  • in state a, reading 1, write B (blank), move
    Right, go to state a
  • in state a, reading B, write B, STOP, go to state
    b
  • This is a program to erase the tape.

28
Turing Machine (6)

Write 'B', move R
Write 'B', move R
Write 'B', STOP
29
Universal TM
  • A TM computes one particular function.
  • Universal TM is one which can simulate any other
    machine.
  • It takes as input a description of a particular
    machine in addition to a copy of the input tape.

30
Turing's Thesis
  • Turing's Thesis The class of effectively
    computable functions can be identified with the
    class of Turing machine computable functions.
  • Universal TM comparable to a real computer.
  • A binary alphabet is sufficient to construct a
    machine to compute any function.
  • TM can perform all of the basic functions of
    computation (or calculation).

31
States
  • A Turing Machine has unlimited memory. Obviously
    memory is a consideration in the real world. A
    Finite State Machine is a Turing Machine but with
    limited memory.
  • http//www.turing.org.uk/turing/scrapbook/tmjava.h
    tml
  • http//ironphoenix.org/tril/tm/

32
Halting Problem
  • Turing's work arose out of his examination of
    Gödel's incompleteness theorem all consistent
    axiomatic formulations of number theory include
    undecidable propositions (can't be either proved
    or disproved).
  • Halting problem the determination of whether a
    TM will come to a halt given a particular input
    program. This problem is undecidable.
  • There are things computers cannot compute.
Write a Comment
User Comments (0)
About PowerShow.com