def reset(self, config, trace): global _engine global _engine_in_use """Reset environment for a new episode using a given config.""" self._waiting_for_game_count = 0 self._steps_time = 0 self._step = 0 self._config = config self._trace = trace self._observation = None self._info = None self._done = False self._config.NewScenario() self._scenario_cfg = self._config.ScenarioConfig() if not self._env: assert not _engine_in_use, ('Environment does not support multiple ' 'instances of the game in the same process.') _engine_in_use = True if not _engine: _engine = libgame.GameEnv() _engine.start_game(self._config.GameConfig()) self._env = _engine self._home_controllers = [] self._away_controllers = [] for _ in range(self._scenario_cfg.home_agents): controller = football_action_set.StickyWrapper(config, self) self._home_controllers.append(controller) for _ in range(self._scenario_cfg.away_agents): controller = football_action_set.StickyWrapper(config, self) self._away_controllers.append(controller) self._env.reset(self._config.ScenarioConfig()) while not self._retrieve_observation(): self._env.step() return True
def reset(self, trace): global _engine global _engine_in_use global _rendering_supported """Reset environment for a new episode using a given config.""" self._waiting_for_game_count = 0 self._steps_time = 0 self._step = 0 self._trace = trace self._observation = None self._info = None self._done = False self._config.NewScenario() self._scenario_cfg = self._config.ScenarioConfig() if not self._env: assert not _engine_in_use, ( 'Environment does not support multiple ' 'instances of the game in the same process.') if not _engine: _engine = libgame.GameEnv() _engine.start_game(self._config.GameConfig()) _rendering_supported = self._config['render'] else: assert _rendering_supported or not self._config['render'], ( 'Enabling ' 'rendering when initially it was disabled is not supported.' ) _engine_in_use = True self._env = _engine self._left_controllers = [] self._right_controllers = [] for _ in range(self._scenario_cfg.left_agents): controller = football_action_set.StickyWrapper(self._config, self) self._left_controllers.append(controller) for _ in range(self._scenario_cfg.right_agents): controller = football_action_set.StickyWrapper(self._config, self) self._right_controllers.append(controller) self._env.reset(self._config.ScenarioConfig()) while not self._retrieve_observation(): self._env.step() return True
def reset(self, trace): """Reset environment for a new episode using a given config.""" global _unused_engines global _unused_rendering_engine self._waiting_for_game_count = 0 self._steps_time = 0 self._step = 0 self._trace = trace self._observation = None self._info = None self._done = False self._config.NewScenario() self._scenario_cfg = self._config.ScenarioConfig() if not self._env: if self._config['render']: if _unused_rendering_engine: self._env = _unused_rendering_engine _unused_rendering_engine = None self.rendering_in_use() else: if _unused_engines: self._env = _unused_engines.pop() if not self._env: if self._config['render']: self.rendering_in_use() self._env = libgame.GameEnv() self._env.start_game(self._config.GameConfig()) self._left_controllers = [] self._right_controllers = [] for _ in range(self._scenario_cfg.left_agents): controller = football_action_set.StickyWrapper(self._config, self) self._left_controllers.append(controller) for _ in range(self._scenario_cfg.right_agents): controller = football_action_set.StickyWrapper(self._config, self) self._right_controllers.append(controller) self._env.reset(self._config.ScenarioConfig()) while not self._retrieve_observation(): self._env.step() return True