Finite State Machine Applications

Finite State Machine Applications
Eric Gribkoff
May 29, 2013
Outline
1 Applications of Finite State Machines
2 Vending Machine
3 Pac-Man
4 TCP
5 Adding Output
Eric Gribkoff | UC Davis
2/11
1 Applications of Finite State Machines
• Vending Machines
• Traffic Lights
• Video Games
• Text Parsing
• CPU Controllers
• Protocol Analysis
• Natural Language Processing
• Speech Recognition
Eric Gribkoff | UC Davis
3/11
Eric Gribkoff | UC Davis
4/11
2 Vending Machine
select
select
start
$0.00
select
$0.25
$0.25
$0.25
$1.00
$0.50
$1.00
select
select
$0.25
$0.75
$1.00
$1.00
$0.25
select
select
$0.25
$1.00
$1.25
$1.50
$1.75
$0.25, $1.00
$0.25, $1.00
$0.25, $1.00
select
$1.00
select
$2.00
$0.25, $1.00
Eric Gribkoff | UC Davis
5/11
3 Pac-Man
Eric Gribkoff | UC Davis
6/11
Spot
Pac-Man
start
Wander the Maze
Reach
Central Base
Chase Pac-Man
Lose
Pac-Man
Pac-Man Eats
Power Pellet
Pac-Man Eats
Power Pellet
Power Pellet
Expires
Return to Base
Flee Pac-Man
Eaten by
Pac-Man
Figure 1: Behavior of a Pac-Man Ghost
Eric Gribkoff | UC Davis
7/11
4 TCP
Eric Gribkoff | UC Davis
8/11
Timeout after two maximum
segment lifetimes (2*MSL)
start
CLOSED
Passive open
Active open/SYN
Close
Timeout/RST
Close
LISTEN
Send/SYN
SYN/SYN + ACK
SYN/SYN + ACK
SYN_RCVD
SYN_SENT
SYN + ACK/ACK
ACK
ACK
ESTABLISHED
Close/FIN
FIN/ACK
Close/FIN
FIN_WAIT_1
CLOSE_WAIT
ACK
Close/FIN
ACK
FIN +
ACK/ACK
CLOSING
FIN_WAIT_2
LAST_ACK
ACK
FIN/ACK
TIME_WAIT
Figure 2: TCP State Diagram
Eric Gribkoff | UC Davis
9/11
5 Adding Output
Finite state machines with an output tape are known as finite state
transducers (FST). A Mealy machine is an example of a deterministic FST.
Instead of accepting or rejecting strings, a Mealy machine maps input
sequences to output sequences.
Eric Gribkoff | UC Davis
10/11
Next: Finite State Transducers