endless-sky/endless-sky

(more persistent) states (state machines) for active ships

Opened this issue · 1 comments

Problem Description

Ships are currently governed by a large set of booleans and target-pointers to determine what a ship is doing and that get evaluated each frame. I feel that moving to state-machines will help improve readability and will allow new features more easily.

Related Issue Links

Some examples of where I expect that the use of state-machines will help:

  • real-time boarding (ships are in boarding state while the game is running, we can also have multiple boarding states more easily)
  • speeding up formation flying (ships are either in a "Flying in a formation state" or in another state being out of the formation, making the formations code more easier to deal with)
  • cleaning up of orders / commands (ships just switch to the right states relevant to the given command(s))

Desired Solution

Using a state machine will likely improve the readability and clarity of the code, and might also help to add some newer features. The different states would typically be implemented as an enum.

Alternative Approaches

Continuing with booleans as we do now is an alternative.

There was also discussion some time in the past to not only have state machines for individual ships, but to also have state-machines for governments. (Affecting government behavior and allowing governments to influence their ships.)

I feel that state machines on ships would be a good starting point, before deploying such a feature at other places.

Additional Context

No response

State machines is what my own space game uses, +100 to this and the reasoning behind it