-
Notifications
You must be signed in to change notification settings - Fork 0
Game.gameLoop is not deterministic #21
Copy link
Copy link
Open
Labels
bugSomething isn't workingSomething isn't workingdesign decision neededDiscussion is needed around implementation detailsDiscussion is needed around implementation detailsgood first issueGood for newcomersGood for newcomershelp wantedExtra attention is neededExtra attention is needed
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't workingdesign decision neededDiscussion is needed around implementation detailsDiscussion is needed around implementation detailsgood first issueGood for newcomersGood for newcomershelp wantedExtra attention is neededExtra attention is needed
Describe the bug
Currently, the game loop is not deterministic -- its behavior depends on outside variables; specifically, the game state. This presents a number of challenges, such as making testing a bit more difficult than it probably should be. For example, in testing, you have to call
game.shutdown()beforegame.gameLoop(), otherwise it will begin actually looping and hang your tests indefinitely.To Reproduce
Steps to reproduce the behavior:
...watch it loop and hang until interrupted.
...watch it loop a single time and then exit.
Expected behavior
The game loop should be fully deterministic. Given the same inputs, it should produce the same outputs and behavior.
Additional context
Also outlined in this report is that this method produces side effects. Specifically, calling
setTimeout(). I'm not really sure there is a way around that. But it sticks out to me in this context, as this bug is calling out the game loop as not being a "pure" function.