SM2220 – Class 10 Finite Automata. SM2220 – Class 10 Finite Automata Computation theory Formal...

38
SM2220 – Class 10 Finite Automata

Transcript of SM2220 – Class 10 Finite Automata. SM2220 – Class 10 Finite Automata Computation theory Formal...

SM2220 – Class 10

Finite

Automata

SM2220 – Class 10

Finite Automata

• Computation theory

• Formal language

SM2220 – Class 10

Finite Automata

• Provides an easy method for the design of

interactive artworks.

• Relates to generative art through the use of

regular grammar.

SM2220 – Class 10

From a functional point of view, computation can

be considered as a black box which takes in

symbols and produces symbols.

ComputationInput symbols Output symbols

SM2220 – Class 10

Using the year 1 Pd or Director program you

have done, the same logic applies.

VJ softwareKeyboard inputs Video clips

SM2220 – Class 10

Imagine this strange Boolean algebra formula,

AND NOTA (1 or 0)

SM2220 – Class 10

The feedback loop introduces the element of

time and most importantly, memory.

AND NOTA

SM2220 – Class 10

The current formula is not very stable. It can

perform better with in introduction of another

input.

AND NOTA

SM2220 – Class 10

AND NOTA

AND NOTB

The following is a more stable memory logic.

SM2220 – Class 10

The memory gives you the state (status) of the

computing device.

The previous one can only remember two states

(1 bit information).

SM2220 – Class 10

Finite Automata is an abstract computing device

capable of remembering finite number of states.

SM2220 – Class 10

A less abstract description?

Nonlinear description of how an

object can change its state over

time, possibly in response to

events in its environment.

The Ultimate Guide to FSMs in Games – Dan Fu and Ryan Houlette

SM2220 – Class 10

It starts at an initial state. By accepting different

inputs, it changes to different states. Eventually,

it stops at an ending state.

SM2220 – Class 10

S0

S1

S2

a

b

b

Simple example

SM2220 – Class 10

The diagram is known as a Graph in

Mathematics. Each state is a node and each

input symbol is a directed link.

A graph is different from a tree that it can

contain a loop.

SM2220 – Class 10

State transition table

Current state Input Next state

S0 a S1

S0 b S2

S1 b S2

SM2220 – Class 10

If you consider the input symbol sequence, you

can notice the valid ones are,

• ab

• b

All the other input symbol sequences are invalid.

SM2220 – Class 10

Essentially this simple finite automata defines a

simple language which has only 2 alphabets: a,

b. And the valid syntax for the language are the

2 sentences: ab and b.

SM2220 – Class 10

Such language is known as,

• Regular language

• Regular grammar

• Regular expression

SM2220 – Class 10

S0

S1 S3

S2

a

a

b

b a

b

a, b

More complicated example

SM2220 – Class 10

Exercise time

• Try to draw the transition table for the finite

automata.

• Try to identify the regular language pattern.

SM2220 – Class 10

Current state Input Next state

SM2220 – Class 10

Current state Input Next state

S0 a S1

S0 b (S2)

S1 a S3

S1 b (S2)

S2 b (S2)

S2 a S1

S3 a S3

S3 b S3

SM2220 – Class 10

To determine the language that the previous

finite automata generates, we can trace the

patterns,

(ab)*b*

b(ab)*b*

SM2220 – Class 10

Applications of Finite Automata

SM2220 – Class 10

If you start replacing the a, b symbols with

sentences, plots, etc., you can end up with a

piece of text like the Oulipo experiments.

SM2220 – Class 10

Gather Treasure

Flee

Fight

Monster in sight

Monster dead

Simple application in game

CorneredMonster away

SM2220 – Class 10

If you start replacing the states: S0, S1, etc. with

scenes, movie clips or frames, you will end up

with an interactive movie. The symbols: a, b will

become your participants’ input, such as sensor

values or keyboard inputs.

SM2220 – Class 10

Now, go back to our job assignment. See if the

idea of Finite Automata can help you out.

SM2220 – Class 10

First, you determine how many states the

artwork requires.

SM2220 – Class 10

Second, for each state, design what actions will

be needed, e.g. to play a video or to stop a

video.

SM2220 – Class 10

Next, you need to figure out for each state, what

type of inputs will lead it to the next state.

Note that each sensor/key has two status, i.e.

from off to on and from on to off.

SM2220 – Class 10

We have 3 sensors (a, b, c in keyboard), which

will be all of our inputs.

SM2220 – Class 10

We have 3 sensors (a, b, c in keyboard), which

will be all of our inputs.

We have 3 outputs (video 1, 2, 3).

SM2220 – Class 10

Start

+a

S1 S2 S3 S4 S5

-a

+b

-b

-a

+a

+c

-c

-b

+b

SM2220 – Class 10

Current state Input Next state

S0 +a S1

S1 -a S0

S1 +b S2

S2 -b S1

S2 -a S3

S3 +a S2

S3 +c S4

S4 -c S3

S4 -b S5

S5 +b S4

SM2220 – Class 10

Input Current state Next state

+a S0 S1

S3 S2

-a S1 S0

S2 S3

+b S1 S2

S5 S4

-b S2 S1

S4 S5

+c S3 S4

-c S4 S3

SM2220 – Class 10

Current state Video playing

S0 -

S1 Video 1

S2 Video 1, 2

S3 Video 2

S4 Video 1, 2, 3

S5 Video 3