Post on 24-May-2015
description
State machines, or, Finite State Automata and the uses thereof
What is a state machine?
Example state machine:
Traffic lights!
I apologise in advance for my 'art'.
This is why I am not a graphic designer.
State Top
State Base
State Pedestrian
State Machine Diagram
State Pedestrian
Entry Action: turn pedestrian lights green.Delay 20 seconds.
Flash pedestrian lights red.Delay 40 seconds.
Exit Action: turn pedestrian lights red.Load State Base
State Base
Entry Action:Turn appropriate lights green.
Delay 40 seconds.Turn off green lights, turn on amber lights.
Delay 15 deconds.
Exit action:Turn off amber lights, turn on red lights.
Load State Top
State Top
Entry Action: as State Base
Input Action:If input, perform exit action and load State Pedestrian.
Otherwise, perform exit action and load State Base
Exit Action: turn all lights red, load next state.
A better way?
A more efficient way!