Exemple #1
0
 def __init__(self, cfg, name='Player1', color='0', map='map01'):
     game = DoomGame()
     game_args = ""
     game_args += " -name %s" % name
     game_args += " -colorset %s" % color
     game.add_game_args(game_args)
     game.load_config(cfg)
     game.set_death_penalty(1)
     game.set_doom_map(map)
     self.env = game
     self.observation_space = spaces.Box(0, 255, game.get_screen_size())
     self.action_space = spaces.Discrete(game.get_available_buttons_size())
     self.reward_range = None
Exemple #2
0
 def __init__(self,
              cfg,
              name='Player1',
              color='0',
              host=True,
              map='map01',
              dm=True,
              port=None,
              num_players=7):
     game = DoomGame()
     game.load_config(cfg)
     game_args = ""
     if host:
         # This machine will function as a host for a multiplayer game with this many
         # players (including this machine). It will wait for other machines to connect using
         # the -join parameter and then start the game when everyone is connected.
         game_args += "-host %s " % num_players
         # The game (episode) will end after this many minutes have elapsed.
         game_args += "+timelimit 10.0 "
         # Players will respawn automatically after they die.
         game_args += "+sv_forcerespawn 1 "
         # Autoaim is disabled for all players.
         game_args += "+sv_noautoaim 1 "
         # Players will be invulnerable for two second after spawning.
         game_args += "+sv_respawnprotect 1 "
         # Players will be spawned as far as possible from any other players.
         game_args += "+sv_spawnfarthest 1 "
         # Disables crouching.
         game_args += "+sv_nocrouch 1 "
         # Sets delay between respanws (in seconds).
         game_args += "+viz_respawn_delay 10 "
         game_args += "+viz_nocheat 1"
         if dm:
             # Deathmatch rules are used for the game.
             game_args += " -deathmatch"
         if port is not None:
             game_args += " -port %s" % port
     else:
         game_args += " -join 127.0.0.1"
         if port is not None:
             game_args += ":%s" % port
     game_args += " -name %s" % name
     game_args += " -colorset %s" % color
     game.add_game_args(game_args)
     game.set_death_penalty(1)
     game.set_doom_map(map)
     self.env = game
     self.observation_space = spaces.Box(0, 255, game.get_screen_size())
     self.action_space = spaces.Discrete(game.get_available_buttons_size())
     self.reward_range = None