Once of the first things programmers should learn about computers is that they are very advanced state machines. A state machine is simply a machine that performs a series of actions, but the actions can vary based on the state of the machine. In the case of the computer, the actions are determined by the operation code contained at the current memory address that the program counter is pointed to. The states are the flags within the processor which are set and cleared based on the actions that the machine performs.
Puzzles within games can also be thought of as state machines. Or, if you find it easier to comprehend, a series of state machines, with some of the machines depending on the state of other machines. Instead of flags and registers, you have objects and actions. In an adventure game, the and in the case of episode 15, obtaining the nut is the state you want to put the machine into. To do this you need to have the nut. This is where having a mini-state machine within the game comes in handy. What is really interesting is that the state of the nut within the game actually helps determine the state of the rock within the game. Likewise, the nut state is dependent in part on the rock state.
The rock has four distinct states. It can be your basic rock, your rock with a husked walnut on it, your rock with a husked walnut on it, or your basic rock that has husk remains around it. The second state depends on the player having the husked walnut. The third state depends on the player having the rock. The fourth state is when the player picks the walnut off the rock.
The nut has three visible states, but internally has five states, one of which is shared with the rock. You have the in tree state, the husk state, the husk on rock state, the walnut state (which could arguably be broken into on rock and in inventory states), and the given to squirrel state.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment