Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Explicit States in EventLoop.hs #14

Open
fendor opened this issue Aug 12, 2018 · 5 comments
Open

Explicit States in EventLoop.hs #14

fendor opened this issue Aug 12, 2018 · 5 comments
Labels
enhancement New feature or request

Comments

@fendor
Copy link
Contributor

fendor commented Aug 12, 2018

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.

@fendor fendor added the enhancement New feature or request label Aug 12, 2018
@samuelpilz
Copy link
Contributor

How to implement that? There are 2 options:

  • state pattern in different variations
  • make illegal state impossible driven approach

@fendor
Copy link
Contributor Author

fendor commented Aug 13, 2018

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

@samuelpilz
Copy link
Contributor

samuelpilz commented Aug 14, 2018

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

@fendor
Copy link
Contributor Author

fendor commented Oct 3, 2018

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:

  • Warmup: In this phase, clients can connect to the game and send game setup messages. Ready up messages should be accumulated.
    • Possible transitions
      • Running: Triggered when the amount of logged in players is equal to the number of players that are ready.
  • Running: Connection Requests are denied, ready up messages are ignored.
    • Possible transitions
      • Paused: How to trigger this transition is not decided yet.
      • Over: Someone has won the game, or everyone disconnected.
  • Paused: Connections are rejected, ready up may be useful.
    • Possible transitions
      • Running: TBD
  • Over: Someone has won or the game is over. Determine what of the two has happened and save it some kind of event list. After a pre determined amount of gameTicks the state transition to Warmup is triggered.
    • Possible transitions
      • Warmup: Triggered after a pre determined amount of ticks have passed.

@fendor
Copy link
Contributor Author

fendor commented Oct 5, 2018

First step of the refactoring has been implemented by #16

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants