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

Option to start the game paused #2076

Closed
xsebek opened this issue Jul 22, 2024 · 7 comments · Fixed by #2080
Closed

Option to start the game paused #2076

xsebek opened this issue Jul 22, 2024 · 7 comments · Fixed by #2080
Assignees
Labels
S-Nice to have The bug fix or feature would be nice but doesn't currently have much negative impact. T-Cmdline Command-line flags and behavior T-Debugging Involves the debugger + related tools Z-Developer Experience This issue seeks to make life easier for developers writing Scenarios or other Swarm code. Z-Feature A new feature to be added to the game.

Comments

@xsebek
Copy link
Member

xsebek commented Jul 22, 2024

Is your feature request related to a problem? Please describe.

Sometimes (#2064), I need to debug the first tick of the game.
That is hard because the game starts in a running state.

Describe the solution you'd like

Add command line option --paused to initialize the game state with the runState == ManualPaused.

Describe alternatives you've considered

I would not mind writing --debug=startPaused from #1324.

Starting with the game paused could be useful for competitive play, but probably not a good default.

@xsebek xsebek added Z-Feature A new feature to be added to the game. S-Nice to have The bug fix or feature would be nice but doesn't currently have much negative impact. Z-Developer Experience This issue seeks to make life easier for developers writing Scenarios or other Swarm code. T-Cmdline Command-line flags and behavior T-Debugging Involves the debugger + related tools labels Jul 22, 2024
@xsebek xsebek self-assigned this Jul 22, 2024
@xsebek
Copy link
Member Author

xsebek commented Jul 22, 2024

I tried to initialize the game while paused and was surprised it did not do anything. Apparently, other game state initialization functions use the scenario description. I wonder if the first game state is used outside of tests.

@xsebek
Copy link
Member Author

xsebek commented Jul 22, 2024

@byorgey to test this, I set the scenario code to always start paused:

diff --git a/src/swarm-engine/Swarm/Game/State/Initialize.hs b/src/swarm-engine/Swarm/Game/State/Initialize.hs
index 5e716353..86715151 100644
--- a/src/swarm-engine/Swarm/Game/State/Initialize.hs
+++ b/src/swarm-engine/Swarm/Game/State/Initialize.hs
@@ -88,6 +88,7 @@ pureScenarioToGameState scenario theSeed now toRun gsc =
   gs = initGameState gsc
   preliminaryGameState =
     gs
+      & temporal . runStatus .~ ManualPause
       & robotInfo %~ setRobotInfo baseID robotList'
       & creativeMode .~ scenario ^. scenarioOperation . scenarioCreative
       & winCondition .~ theWinCondition

This gets to a really strange state where the side panels are empty, and the goal is not yet shown, but REPL works:
Screenshot 2024-07-23 at 0 12 12

After one step with C-o, the panels load, and the goal modal pops up.

@kostmo
Copy link
Member

kostmo commented Jul 23, 2024

Not quite the same as pausing, but sometimes for debugging I have started the game at a very slow speed, e.g.:

scripts/play.sh -i Tutorials/move --autoplay --speed -3

@xsebek
Copy link
Member Author

xsebek commented Jul 23, 2024

Thanks for the tip @kostmo !

I will try that out, though I would expect speed 0 to mean 0 ticks per second.

@byorgey
Copy link
Member

byorgey commented Jul 23, 2024

Speed n means 2^n ticks per second. We should improve the help text to make that clearer. Right now it says "Initial game speed multiplier" which seems ambiguous at best.

@noahyor
Copy link
Member

noahyor commented Jul 23, 2024

This gets to a really strange state where the side panels are empty, and the goal is not yet shown, but REPL works.

@xsebek, This is because the Inventory and Info panels update on Frame events, which causes this strange behavior.

I had to deal with this when I was integrating Swarm with Termite, because I forgot to spawn a thread which sends Frame events.

@xsebek
Copy link
Member Author

xsebek commented Jul 28, 2024

Thanks for the info, @noahyor; I will file a separate Issue to update the panels at the start. 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-Nice to have The bug fix or feature would be nice but doesn't currently have much negative impact. T-Cmdline Command-line flags and behavior T-Debugging Involves the debugger + related tools Z-Developer Experience This issue seeks to make life easier for developers writing Scenarios or other Swarm code. Z-Feature A new feature to be added to the game.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants