A Different Path

Learn to build a state machine to embody the rules.

Functional state machine

You might think we could make decisions about the application stages, stage transitions, and events with conditional logic. You would be right, but the costs would be high. The number of nested if statements necessary to do the job would lead to a snarl of code paths. We would face real readability and maintainability problems.

Therefore, we’re going to choose a different direction. We’ll implement our own purely functional state machine to handle all the stages that Islands will go through in the course of a full game. It’s going to make decisions for the application about which actions to allow and which to deny at a given stage. It will manage transitions ...