duyminh1998 / pycmo

Command Modern Operations Learning Environment
Other
49 stars 23 forks source link

How does time compression interact with time triggers #36

Closed duyminh1998 closed 9 months ago

duyminh1998 commented 9 months ago

We need to know more about

how the in-game time compression interacts with the regular time triggers that are set

So that

we can increase the speed of the game safely (ensuring that important events are still fired correctly) and minimize training times

Questions to answer

  1. Are time compression and regular time triggers independent of each other?
  2. If a user sets the game to use the maximum speed, will triggers that fire every X seconds use the time passed in-game or the CPU clock?
  3. If we set a trigger to fire every X seconds and use the max time compression, will that trigger still fire every X seconds reliably?
duyminh1998 commented 9 months ago

We seem to be able to use turbo and double turbo speeds with RegularTime triggers, provided they are large enough (i.e. >= 1 minute). The issue seems to be that if we set the RegularTime trigger duration to be too small and the time compression too large, the game does not have enough time to output observations before it pauses. When the game pauses, no Lua action can fire. For some reason, our ScenEdit_ExportScenarioToXML function is not guaranteed to succeed, either because (1) the game is not executing the Lua scripts sequentially (some threading involved? maybe we need to make the functions call block), or (2) like https://github.com/duyminh1998/pycmo/issues/33 and https://github.com/duyminh1998/pycmo/issues/25, sometimes the game fails to completely run a Lua script.

duyminh1998 commented 9 months ago

It looks like it is not the environment's fault. When we set the event export time trigger in the floridistan demo to 15 seconds and use turbo speed, for the first few times the scenario pauses, time does not advance. We have to click close message (on the popup that pauses the game when we export observations) a few times before time finally advances. This does not happen when the time trigger is set to larger intervals. Could there be set up code that needs to run in the beginning of the scenario that requires some buffering time? In either case, we need to put guards in our environment to check when time is not advancing when we know that it should.

duyminh1998 commented 9 months ago

There is a bad interaction between the game ending and the scenario paused message popup. We need to ensure that we cleared the scenario paused message before we fire scripts to clear the scenario ended messages.

duyminh1998 commented 9 months ago

With https://github.com/duyminh1998/pycmo/pull/42 we can basically support running pyCMO with Command on turbo or double turbo speeds.