Hard Tweets Explained: Finite State Machine

Let’s start with a literal interpretation. If the continent could produce states forever, it would be an infinite producer of states. So it would be an infinite state-making machine. But eventually we used up all the space, so it was a finite state-making machine, or finite state machine.

The reason this is ahem “funny” is because Finite State Machine is a term of art in computer science. That is, it is computer jargon for a particular way of writing a computer program. You model the behavior of the system by listing all the states that it might be in. There is a limited number of these, and hence, “finite.” Then you work out under what conditions it will transition from one state to another.

For example, suppose you are writing a program that scans a text file line by line, and prints any section bounded by a three dashes. This program would start in a state “looking for dashes”. When you are in this state if you see the dashes, you transition to the state “printing stuff”. When you are in this state you print each line you see, and check to see if you see dashes again. When you see the dashes, you transition to back to the “looking for dashes” state. There are just those two states in this machine.

FSM for your Vibrator

FSM for your Vibrator

Finite State Machines (often abbreviated FSMs) are useful for building programs that are extremely robust. Often you can represent the states as rows in a table, and the inputs as columns, and the transitions in the cells of the table. That allows you to write a very simple program and then do all your programming by filling in the table. It’s easier to be certain that a table is correct than it is to get that certainty about a program, so this technique is often used in systems that are mission-critical like your car stereo or the microcontroller in that fancy three-speed vibrator you just bought.

Homework: Try to reach orgasm with your vibrator while simultaneously thinking about the fact that there is a FSM micro controller program involved.


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s