pysc2 icon indicating copy to clipboard operation
pysc2 copied to clipboard

bin/agent viewer can't control the speed nor pause

Open luwei0917 opened this issue 6 years ago • 7 comments

I tried to pause the replay generated by "python -m pysc2.bin.agent --map DefeatRoaches". but no effect. I'm using a Windows machine.

luwei0917 avatar Aug 12 '17 04:08 luwei0917

I assume you mean parse, not pause. If you do mean pause and are running with pysc2.bin.play, hit the pause button on your keyboard.

Is there an error message? If you run "python -m pysc2.bin.replay_info " where does it say the map is?

tewalds avatar Aug 12 '17 08:08 tewalds

I realize it is not only the pause button not function. but also the "increase speed" and "decrease speed" button have no real effect on the replay.(except the game time is shown to change from normal to faster x8"

There is no error message except a warning at the very beginning.

WARNING:root:Terminating attempt 0... WARNING:root:Terminated.

map_name: "CombatFocus" local_map_path: "mini_games/DefeatRoaches.SC2Map" player_info { player_info { player_id: 1 race_requested: Terran race_actual: Terran } player_result { player_id: 1 result: Tie } player_apm: 193 } player_info { player_info { player_id: 2 race_requested: Zerg race_actual: Zerg } player_result { player_id: 2 result: Tie } player_apm: 0 } game_duration_loops: 20032 game_duration_seconds: 894.34814453125 game_version: "3.16.1.55958" data_build: 55958 base_build: 55958 data_version: "5BD7C31B44525DAB46E64C4602A81DC2"

luwei0917 avatar Aug 12 '17 15:08 luwei0917

When playing a replay through the API, the in-game replay control UI is not supported. Pausing and speed is controlled through the API in this case.

If you want to use the regular in-game controls, you can just launch the replay through the regular game UI.

KevinCalderone avatar Aug 12 '17 18:08 KevinCalderone

Hmm, I just tried this. pysc2.bin.agent doesn't support pausing or controlling the speed, but pysc2.bin.play does for both --map and --replay. Does this match what you're seeing?

Is it important that an agent can play at a controlled speed? It seems like you'd want the agent to play as quickly as possible.

tewalds avatar Aug 12 '17 19:08 tewalds

My keyboard doesn't have PgUp/PgDn, and Puase button. I can use on screen keyboard for now. but I hope it can be easier.(like being able to control through UI. Thanks.

luwei0917 avatar Aug 13 '17 02:08 luwei0917

The challenge here is the environment sends observations to render but doesn't go through the renderer's run loop. The renderer can't use the normal agent/env run loop since the renderer needs privileged observations (ie the raw api) to render units. This control inversion relative to bin/play.py makes it hard to support.

It's also not clear to me that this is something we care about. You'd usually want to run the agent as fast as possible so it can learn, but then just view them once in a while, which you can do at whatever speed you want using replays.

tewalds avatar Aug 19 '17 13:08 tewalds

For me worked modifying pysc2\env\run_loop.py after line 38 added frame_start_time = time.time() and after 46: timesteps = env.step(actions) time.sleep(max(0, frame_start_time + 1 / 10 - time.time()))

Later my plan is to add a condition with checking some custom flag. For me it is usefull to see whats heppening, and later speed up the learning. (Installed pysc2 from git using "pip install -e ." in directory with setup.py) Don't forget to delete pysc2\env\__pycache__ folder after modifying the code.

p.s. Also don't forget to run agent with --step_mul 1 or configure it in your script like flags.DEFINE_integer("step_mul", 1, "Game steps per agent step.")

NesCafe62 avatar Mar 20 '18 09:03 NesCafe62