Editorial illustration: State Machines: Where Is the Game Right Now?

State Machines: Where Is the Game Right Now?

Three names for three phases

A state machine gives names to phases and makes allowed transitions explicit. Waiting for input, resolving a move and showing results have different permissions. A turn-based game becomes easier to reason about when input cannot accidentally commit another move during resolution.

A turn-based game can have choosing, executing and displaying-result phases. Each has an input policy: choosing accepts card input, executing rejects a second committed move, and the result may accept restart. Before writing a class, sketch these names and transitions. If you cannot describe when a transition completes, code will not resolve the ambiguity; it will distribute it across conditions. A readable phase plan is useful even before deciding how the implementation stores state.

A second click during resolution

Draw three named states for a small turn: awaiting selection, resolving selection and ready for the next turn. List the allowed input in each. Try confirming twice while resolution is underway. The expected behavior should come from the state contract, not from how quickly the animation finishes. Add one explicit exit route to see whether a pending choice is canceled or completed safely.

Try two rapid card taps. Once the first enters execution, the second must follow that phase’s policy rather than award points again. It could be ignored or preserve a visual selection, depending on the contract. Logical resolution and animation completion may occur at different moments; identify who advances the phase. Several booleans can create impossible combinations. An explicit phase name often communicates the intended situation more clearly than independently toggled flags.

State differs from appearance

On restart, prepare required data before returning to choosing. Renaming the phase does not clear previous cards. A shared data asset such as ScriptableObject can hold configuration, but does not automatically create transitions or a state machine. For review, record which controls work in each phase and what leaving the screen does. This short contract can be compared directly with gameplay, making it more useful than an elaborate diagram with undefined behavior.

Further reading: Unity: ScriptableObject

For a related example, read Dalo’s Shared Core: One Table, Several Games.

Latest blog posts

Independent editorial illustration about Unity Godot Unreal comparison

Unity, Godot or Unreal: Comparing Engines for One Project

Compare engines against the same small project requirements. Rendering needs, export targets, available skills and maintenance matter more than a general.

Read article
Five cute creepy elemental creatures fire ice pumpkin wind shadow

BoomBo: Exploring Elemental Character Concepts

The early visual direction for BoomBo explores cute-creepy elemental characters: pumpkin, fire, ice, wind and shadow. The goal is to make the cast.

Read article
Editorial illustration: Memory Budgets: Assets Have a Cost

Memory Budgets: Assets Have a Cost

Images, audio and runtime objects all occupy memory, even when their files look small on disk.

Read article
Dalo