Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def dump_to_video(self, dump_file):
dump = self.load_dump(dump_file)
cfg = config.Config(dump[0]['debug']['config'])
cfg['dump_full_episodes'] = True
cfg['write_video'] = True
cfg['display_game_stats'] = True
processor = observation_processor.ObservationProcessor(cfg)
processor.write_dump('episode_done')
for frame in dump:
processor.update(frame)
def reset(self, inc=1):
"""Reset environment for a new episode using a given config."""
self._episode_start = timeit.default_timer()
self._action_set = football_action_set.get_action_set(self._config)
trace = observation_processor.ObservationProcessor(self._config)
self._cumulative_reward = 0
self._step_count = 0
self._trace = trace
self._reset(self._env.game_config.render, inc=inc)
while not self._retrieve_observation():
self._env.step()
return True
def set_state(self, state):
assert (self._env.state == GameState.game_running or
self._env.state == GameState.game_done), (
'reset() must be called before set_state()')
res = self._env.set_state(state)
assert self._retrieve_observation()
from_picle = six.moves.cPickle.loads(res)
self._state = from_picle['FootballEnvCore']
if self._trace is None:
self._trace = observation_processor.ObservationProcessor(self._config)
return from_picle
def reset(self):
"""Reset environment for a new episode using a given config."""
self._episode_start = timeit.default_timer()
self._action_set = football_action_set.get_action_set(self._config)
self._trace = observation_processor.ObservationProcessor(self._config)
self._cumulative_reward = 0
self._step_count = 0
self._env.reset(self._trace)
self._env_state = 'game_started'