A "finite state machine" or FSM is a way of conceptualizing an entity that has specific and discreet states - in other words, the object can only have one state at a time. With well-chosen states, we can create complex-seeming behavior that can mimic physical conditions (how the entity moves) or emotional states (angry, curious, idle).
👩💻 https://editor.p5js.org/jeffThompson/...
👩💻 https://editor.p5js.org/jeffThompson/...
ALL THE VIDEOS IN THIS UNIT
🎥 • CP2: Week 08 (Simulation)
SEE ALSO
💡 http://en.wikipedia.org/wiki/Finite-s...
💡 https://software.intel.com/en-us/arti...
💡 http://gamedevelopment.tutsplus.com/t...
CHALLENGES
❓ Can you have the "flee" state to be triggered when the player attacks, maybe by clicking or hitting the spacebar?
❓ Can you give the zombie a better "idle" state? Hint: try "sin()"
❓ Can you make lots of zombies who all "listen" to each other and change states based on the state of their neighbor? For example, if one zombie is in "seek" mode, all zombies seek to the target. It will likely help if you convert this code to an object-oriented approach.