Download presentation
Presentation is loading. Please wait.
1
Crazy Hat & Candy Machine
B G R R B G R B G R B G
2
Crazy Hat & Candy Machine 2
B G R R G B G R B R B G
3
Fickle Fruit Solution Legend: STATES are vertices of the graph.
The following directed graph diagram represents the behavior of the fruit vendor in the Fickle Fruit exercise. We use "a" for apple and "b" for banana so that "a/b" means "asked for an apple, and received a banana." Start Legend: STATES are vertices of the graph. TRANSITIONS are directed edges... START state indicated by short arrow input causes transition output given en route to next state
4
Frustrating Fruit Solution
There is only one slight difference between this machine and the previous one (the loop transition on the "HAT" state gives a banana instead of an apple)!
5
FSM output variations i/o output on transitions (“Mealy machine”)
name ouput output at states (“Moore machine”) recognizer or acceptor: A special Moore machine where some states say “YES!” (indicated by a double-circle), and the rest have no output. The input sequences leading to YES! are said to be recognized. Example: even odd 1 • Usually, the different output styles are not used in the same FSM, as one approach best suits the situation
6
Fancy Fruit Solution Here is one solution to the Fancy Fruit problem.
Notice that states "HAT and LEI" and "NOTHING" have exactly the same transitions out of them: If you ask for a banana you are given a banana and you go to state "LEI ONLY", and if you ask for an apple you are given an apple and you go to state "APPLE ONLY". Since these two states are exactly the same, we can combine them into one called"(HAT and LEI) or (NOTHING)". Then the diagram looks like this:
7
FSM Design Considerations
What are the inputs to the problem? Are there any outputs? Is the machine a recognizer, or are there different types of output, and if so, do they more naturally seem to go along transitions, with the input, or once a new state is arrived at? STATES vs TRANSITIONS. There is a kind of chicken-and-egg problem: - You can’t tell what the transitions are without knowing what the states are that you are transitioning between. - You can’t tell what the states are, unless you have a good idea of how they should change as input is read. Sometimes one of the two will be clear, and the other will follow. Otherwise, remember: The STATES capture the entire current “state of the entire system” that is being modeled. Each state is a “current snapshot” of what the system is like at this moment. All future behavior must be determinable from the current state and future inputs - how the FSM got to the current state is irrelevant.
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.