CSC 216/s08/diminish fear

From Expertiza_Wiki
Jump to navigation Jump to search

Formatting Resources

Formatting Help Guide from MetaWiki

The Gumball Finite State Machine

The problem

To teach the student about finite state machines.

Participants and props

The participants include those who will volunteer. The props are the students, printed out instructions, and diagram (as seen below [still in the process of being completed]).

The script

A simple example that can be used to demonstrate the finite state machine is a candy dispenser. This is a special kind of candy dispenser that only takes dimes and nickels. Every item in the dispenser cost 20 cents. Assign one of the volunteers to be the current state. Everyone else becomes a different state. In this example, there are 6 different states: 0 cents, 5 cents, 10 cents, 15 cents, and 20 cents, 25 cents.

Once everyone has been assigned a state, display the state transition diagram. The professor then should give input values and have the students run through the simulation with the "current state" student standing next to the correct "state" student.

Here is an example run through.
1. The "current state" student stands next to the "0 cent" state.
2. The professor says he deposits 5 cents.
3. The "0 cent" student tells the "current state" student to go to the "5 cents" student.
4. The professor says he deposits 10 cents.
5. The "5 cents" student tells the "current state" student to go to the "15 cents" student.
6. The professor says he deposits 10 cents.
7. The "15 cents" student tells the "current state" student to go to the "25 cents" student.
8. The "25 cent" student tells the "current state" student to go to the "0 cent" student. This student should also announce that the machine should dispense the candy and also give 5 cents worth of change back.

Sample diagram

http://www.mcbrosmusic.com/CSC/gumball.png