Пример #1
0
    def __init__(self, scenario_path="scenarios/defend_center.cfg"):
        self.reward = 0
        game = DoomGame()
        game.load_config(
            scenario_path
        )  # This corresponds to the simple task we will pose our agent\
        # game.load_config("../../scenarios/cig.cfg")

        game.set_doom_map("map01")  # Limited deathmatch.
        # game.set_doom_map("map02")  # Full deathmatch.
        game.set_window_visible(False)

        # Start multiplayer game only with your AI (with options that will be used in the competition, details in cig_host example).
        game.add_game_args(
            "-host 1 -deathmatch +timelimit 1.0 "
            "+sv_forcerespawn 1 +sv_noautoaim 1 +sv_respawnprotect 1 +sv_spawnfarthest 1"
        )

        # Name your agent and select color
        # colors: 0 - green, 1 - gray, 2 - brown, 3 - red, 4 - light gray, 5 - light brown, 6 - light red, 7 - light blue
        game.add_game_args("+name AI +colorset 0")

        self.game = game

        # generates the the actual action arrays [True, False, False], etc for each action...
        # In preparation for actually using config files....
        self.real_actions = [[
            i == j for i in range(game.get_available_buttons_size())
        ] for j in range(game.get_available_buttons_size())]

        self.last_variables = None

        self.reset()
        game.init()
Пример #2
0
def create_game(
        environment_config: EnvironmentConfig
) -> t.Tuple[DoomGame, ActionList]:
    """Creates an instance of VizDoom.

    Args:
        scenario: The name of the scenario to play.
        environment_config: An environment configuration instance.

    Returns:
        A Doom game instance that respects OpenAI's gym interface.
    """
    game = DoomGame()

    # Game configuration
    game.load_config(f'{paths.SCENARIOS}/{environment_config.scenario}.cfg')
    game.set_doom_scenario_path(
        f'{paths.SCENARIOS}/{environment_config.scenario}.wad')
    game.set_mode(environment_config.game_mode)
    game.set_screen_format(environment_config.screen_mode)
    game.init()

    possible_actions = controls.get_available_actions(
        game.get_available_buttons())

    return game, possible_actions
Пример #3
0
    def __init__(self, params):
        self.game = DoomGame()
        self.game.load_config("../scenarios/" + params.scenario + ".cfg")

        if params.model == 'human':
            self.game.set_mode(Mode.SPECTATOR)
        else:
            self.actions = create_actions(params.scenario)
Пример #4
0
    def _create_doom_game(self, mode):
        self.game = DoomGame()

        self.game.load_config(self.config_path)
        self.game.set_screen_resolution(self.screen_resolution)
        self.game.set_seed(self.rng.randint(0, 2**32 - 1))

        if mode == 'algo':
            self.game.set_window_visible(False)
        elif mode == 'human' or mode == 'replay':
            self.game.add_game_args('+freelook 1')
            self.game.set_window_visible(True)
        else:
            raise Exception('Unsupported mode')

        self._set_game_mode(mode)
Пример #5
0
 def _setup_game(self):
     self.game = DoomGame()
     self.file_path = os.path.dirname(__file__)
     self.game.load_config(os.path.join(self.file_path, "basic.cfg"))
     self.game.set_doom_scenario_path(
         os.path.join(self.file_path, "basic.wad"))
Пример #6
0
 def __init__(self):
     """
     Default constructor.
     """
     super(ViZDoomGame, self).__init__()
     self._game_instance = DoomGame()