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

Decoupling UI event handler and game simulation #912

Open
TristanCacqueray opened this issue Dec 14, 2022 · 2 comments
Open

Decoupling UI event handler and game simulation #912

TristanCacqueray opened this issue Dec 14, 2022 · 2 comments
Labels
C-Project A larger project, more suitable for experienced contributors. S-Moderate The fix or feature would substantially improve user experience. T-UI Involves the user interface. Z-Feature A new feature to be added to the game. Z-Performance This issue concerns memory or time efficiency of the Swarm game. Z-Refactoring This issue is about restructuring the code without changing the behaviour to improve code quality.

Comments

@TristanCacqueray
Copy link
Collaborator

Is your feature request related to a problem? Please describe.
When the game is running slow, as with the game of life scenario, the UI is not responsive.

Describe the solution you'd like
The game simulation, e.g. the robot ticks, should happen in a dedicated thread, outside of the brick event handler.
However this is presently not possible because of the tight coupling between UI and Game state.
In order to achieve this feature, it seems like we need to:

  • Changes handleEvent :: BrickEvent Name AppEvent -> EventM Name AppState () to handleEvent :: GameState -> BrickEvent Name AppEvent -> EventM Name UIState ().
  • Use some sort of a signal callback so that the UI can change the GameState, e.g. signal Pause.
  • Handle the game simulation in place of using the Frame bchan forever loop, and interpret the signal event asynchronously.
@TristanCacqueray TristanCacqueray added the Z-Feature A new feature to be added to the game. label Dec 14, 2022
@kostmo kostmo added the Z-Performance This issue concerns memory or time efficiency of the Swarm game. label May 29, 2023
@byorgey byorgey added Z-Refactoring This issue is about restructuring the code without changing the behaviour to improve code quality. C-Project A larger project, more suitable for experienced contributors. S-Nice to have The bug fix or feature would be nice but doesn't currently have much negative impact. T-UI Involves the user interface. labels May 9, 2024
@xsebek
Copy link
Member

xsebek commented Jul 22, 2024

This would be very useful in scenarios with many robots, like the move tutorial. #2064

The FPS/TPS widget would probably also work better when separated. #2061

Eventually, something tells me players might be tempted to create whole swarms of robots and run into freezing UI. I am going to raise the severity.

@xsebek xsebek added S-Moderate The fix or feature would substantially improve user experience. and removed S-Nice to have The bug fix or feature would be nice but doesn't currently have much negative impact. labels Jul 22, 2024
@TristanCacqueray
Copy link
Collaborator Author

Please note that I wrote this issue after the first swarm swarm, and that the description is not really thought-out. Perhaps this could also supports a future GUI, like a OpenGL render would be pretty neat :-)

Keep up the good work!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-Project A larger project, more suitable for experienced contributors. S-Moderate The fix or feature would substantially improve user experience. T-UI Involves the user interface. Z-Feature A new feature to be added to the game. Z-Performance This issue concerns memory or time efficiency of the Swarm game. Z-Refactoring This issue is about restructuring the code without changing the behaviour to improve code quality.
Projects
None yet
Development

No branches or pull requests

4 participants