Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def _construct_players(self, definitions, config):
result = []
left_position = 0
right_position = 0
for definition in definitions:
(name, d) = cfg.parse_player_definition(definition)
config_name = 'player_{}'.format(name)
if config_name in config:
config[config_name] += 1
else:
config[config_name] = 0
try:
player_factory = importlib.import_module(
'gfootball.env.players.{}'.format(name))
except ImportError as e:
logging.error('Failed loading player "%s"', name)
logging.error(e)
exit(1)
player_config = copy.deepcopy(config)
player_config.update(d)
player = player_factory.Player(player_config, self._config)
if name == 'agent':
def __build_players(self, dump_file, spec):
players = []
for player in spec:
players.extend(['replay:path={},left_players=1'.format(
dump_file)] * config.count_left_players(player))
players.extend(['replay:path={},right_players=1'.format(
dump_file)] * config.count_right_players(player))
return players
@cfg.log
def write_dump(self, name):
return self._trace.write_dump(name)
@cfg.log
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'
def __build_players(self, dump_file, spec):
players = []
for player in spec:
players.extend(['replay:path={},left_players=1'.format(
dump_file)] * config.count_left_players(player))
players.extend(['replay:path={},right_players=1'.format(
dump_file)] * config.count_right_players(player))
return players