FailWhaleBrigade / water-wars

Game in Haskell
Other
14 stars 4 forks source link

Explicit States in EventLoop.hs #14

Open fendor opened 6 years ago

fendor commented 6 years ago

Explicit State

The EventLoop.hs is the core file for the Server Application. It manages multiple connections, it manages the communication, server updates, also whether the game has started, when a game is over, et cetera...

These are a lot of responsibilities, and a lot of the message handling is dependent on the current state. However, the current state of the server and the various client connections are only present through implicit conversion of the current state variables.

My proposal would be, to refactor the server variables to include a more explicit state machine. Hence, messages should have it easier to determine the current state. It should even improve performance by avoiding costly variable analysis during handling a message.

samuelpilz commented 6 years ago

How to implement that? There are 2 options:

fendor commented 6 years ago

I would aim at making illegal states impossible, as much as possible

samuelpilz commented 6 years ago

Then, a description of the Model is reqired in plain text. From that, a suitable data structure can be derived

fendor commented 6 years ago

About making illegal states impossible: It seems hard and kind of impossible to actually do that since the state is determined at runtime. However, the identified states are as follow:

fendor commented 6 years ago

First step of the refactoring has been implemented by #16