Skip to content

Commit 330f8fc

Browse files
PySC2 Teamtewalds
authored andcommitted
Fix the episode_steps counter following the change to support step_mul.
Also validate the step_mul passed to step() to ensure that it is positive. PiperOrigin-RevId: 212281670
1 parent 5ab11a7 commit 330f8fc

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

pysc2/env/sc2_env.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -460,9 +460,12 @@ def step(self, actions, step_mul=None):
460460
return self._step(step_mul)
461461

462462
def _step(self, step_mul=None):
463-
step_mul_ = step_mul or self._step_mul
464-
with self._metrics.measure_step_time(step_mul_):
465-
self._parallel.run((c.step, step_mul_) for c in self._controllers)
463+
step_mul = step_mul or self._step_mul
464+
if step_mul <= 0:
465+
raise ValueError("step_mul should be positive, got {}".format(step_mul))
466+
467+
with self._metrics.measure_step_time(step_mul):
468+
self._parallel.run((c.step, step_mul) for c in self._controllers)
466469

467470
return self._observe()
468471

@@ -508,8 +511,8 @@ def _observe(self):
508511
elif cmd == renderer_human.ActionCmd.QUIT:
509512
raise KeyboardInterrupt("Quit?")
510513

511-
self._total_steps += self._step_mul
512-
self._episode_steps += self._step_mul
514+
self._total_steps += self._agent_obs[0].game_loop[0] - self._episode_steps
515+
self._episode_steps = self._agent_obs[0].game_loop[0]
513516
if self._episode_length > 0 and self._episode_steps >= self._episode_length:
514517
self._state = environment.StepType.LAST
515518
if self._discount_zero_after_timeout:

0 commit comments

Comments
 (0)