An emotion state machine
What is a state machine? We covered state machines in the systems engineering section of Chapter 2 – state machines are a technique for understanding or modeling automation or computer programs. A state is a set of conditions that exist at the present. I like to think of a state as being a set of functions that are constrained by limits. The machine (our robot) changes from state to state based on some event that causes the state to change.
Let’s work through a quick refresher example. Let’s take a slice of bread. When we get it, it is already baked and sliced, so its initial state is as a slice of bread. If we subject the bread to infrared radiation (that is, heat), then the surface becomes caramelized, and we call that toast. The state of the bread has changed, along with its taste and texture, from baked bread to toast. The event that caused that transition was the act of heating the bread in a toaster. This is pretty simple stuff...