|FSM: The Finite State Machine|
A finite state machine isn't a crazy type of machine. A finite state machine is one way to write programs. A finite state machine is usually just called a FSM.
A FSM is made up of two things. First, it has some writing about what's happening. Then, it has some arrows that show different choices you can make. You should make a choice and follow the arrow.
FSMs are good for making games and stories. Here is one game where you have to find some treasure. First, go to Start. Then, you just follow the arrows until you get to the end.
Here is a simpler FSM that lets you explore the rooms of a house.
Let's try making a program that lets you explore the house. First, number all of the rooms.
Now we'll start programming. When programming a FSM, you need the computer to know which room you are in. You should start in room 1.
The computer should tell you something different depending on which room you are in.
The computer should also ask you where you want to go. The computer should then change the room number depending on your answer.
After your room has changed, the computer should go back to the beginning and tell you about the new room. You can use a loop for this.
That's it! You can run the program now. You will be able to move through the different rooms.
Try taking the FSM for the treasure game and programming it into the computer. Then, try making your own FSM game.