Lecture 17 - State Machines, Combinatorics, Game Strategies Flashcards
What does a finite state machine have? (4)
- a set of states
- a set of transitions between the states
- an initial state
- zero or more final (“accepting”) states
What are side effects of a state machine?
The actions taken on entering/leaving states
Can a state machine be between states?
No. State transitions are considered “atomic”
- What are the externally visible parts of a state machine? (3)
- What’s not externally visible?
1.
- – the events the state machine understands
- – the guard conditions the machine checks
- – the actions that the machine performss
- Everything else, including the machine’s current state
What’s a finite state transducer?
If the action on entering/leaving a state is to output a symbol, we call the FSM a finite state transducer. – it converts (transduces) the sequence of input symbols into a sequence of output symbols
What are the types of FSTs? (2)
- Mealy machines
- Moore machines
What’s a mealy machine?
(output symbol is associated with transition)
What’s a Moore machine?
(output symbol is associated with state)
Compare Moore and Mealy machines (3)
- Moore machines in general have many more states than the equivalent Mealy machine –
- because output depends only on current state, not state+input
- so we need to add states whenever the Mealy machine has different outputs for different transitions out of a state
What’s an example of a time when state machines are beneficial?
- Retrieving content based on a user’s mouse click. During retrieval, they click something again.
- The logic might get complicated in an ordinary flow chart, but a state machine wouldn’t accept this 2nd click because it’s in the fetching state, so the 2nd click wouldn’t cause problems.
What are the two common approaches for implementing state machines?
- switch statement
- transition table
Why does the factorial function keep appearing in things we’ve been doing this semester?
It’s the number of permutations of N items
How many permutations are there of k elements from a set of n elements total
n! / (n-k)!
Define combination
A combination is a subset of k elements from a set of n elements