Ejemplo n.º 1
1
def init(buttons):
    print("init")
    game = DoomGame()
    game.set_vizdoom_path("../../ViZDoom/bin/vizdoom")
    game.set_doom_game_path("../../ViZDoom/scenarios/freedoom2.wad")
    game.set_doom_scenario_path("../../ViZDoom/scenarios/basic.wad")
    game.set_doom_map("map01")
    game.set_screen_resolution(ScreenResolution.RES_320X240)
    game.set_screen_format(ScreenFormat.RGB24)
    game.set_depth_buffer_enabled(True)
    game.set_labels_buffer_enabled(True)
    game.set_automap_buffer_enabled(True)

    # Sets other rendering options
    game.set_render_hud(False)
    game.set_render_minimal_hud(False)
    game.set_render_crosshair(False)
    game.set_render_weapon(True)
    game.set_render_decals(False)
    game.set_render_particles(False)
    game.set_render_effects_sprites(False)

    # Adds buttons that will be allowed.
    for button in buttons:
        game.add_available_button(button)

    # Adds game variables that will be included in state.
    game.add_available_game_variable(GameVariable.AMMO2)
    game.add_available_game_variable(GameVariable.SELECTED_WEAPON)

    # Causes episodes to finish after 200 tics (actions)
    game.set_episode_timeout(300)

    # Makes episodes start after 10 tics (~after raising the weapon)
    game.set_episode_start_time(10)

    # Makes the window appear (turned on by default)
    game.set_window_visible(True)

    # Turns on the sound. (turned off by default)
    game.set_sound_enabled(True)

    # Sets the livin reward (for each move) to -1
    game.set_living_reward(-1)

    # Sets ViZDoom mode (PLAYER, ASYNC_PLAYER, SPECTATOR, ASYNC_SPECTATOR, PLAYER mode is default)
    game.set_mode(Mode.PLAYER)

    # Initialize the game. Further configuration won't take any effect from now on.
    # game.set_console_enabled(True)
    game.init()
    return game
Ejemplo n.º 2
0
def doom_game():

  game = DoomGame()
  #game.load_config("../scenarios/basic.cfg") 
  game.load_config("../scenarios/defend_the_center.cfg")
  #game.set_doom_map("map01")
  game.set_screen_resolution(ScreenResolution.RES_320X240)
  #game.set_screen_resolution(ScreenResolution.RES_640X480)
  game.set_render_hud(False)
  game.set_render_crosshair(False)
  game.set_render_weapon(True)
  game.set_render_decals(False)
  game.set_render_particles(False)
  #game.add_available_button(Button.MOVE_LEFT)
  #game.add_available_button(Button.MOVE_RIGHT)
  game.add_available_button(Button.TURN_LEFT)
  game.add_available_button(Button.TURN_RIGHT)
  game.add_available_button(Button.ATTACK)
  game.set_episode_timeout(2100)
  game.set_episode_start_time(10)
  game.set_window_visible(True) #False)
  game.set_sound_enabled(False)
  game.set_living_reward(0.2) # -1 for basic
  game.set_mode(Mode.PLAYER)
  game.init()
  return game
Ejemplo n.º 3
0
# Sets resolution. Default is 320X240
game.set_screen_resolution(ScreenResolution.RES_640X480)

# Sets the screen buffer format. Not used here but now you can change it. Defalut is CRCGCB.
game.set_screen_format(ScreenFormat.RGB24)

# Sets other rendering options
game.set_render_hud(False)
game.set_render_crosshair(False)
game.set_render_weapon(True)
game.set_render_decals(False)
game.set_render_particles(False)

# Adds buttons that will be allowed.
game.add_available_button(Button.MOVE_LEFT)
game.add_available_button(Button.MOVE_RIGHT)
game.add_available_button(Button.ATTACK)

# Adds game variables that will be included in state.
game.add_available_game_variable(GameVariable.AMMO2)

# Causes episodes to finish after 200 tics (actions)
game.set_episode_timeout(200)

# Makes episodes start after 10 tics (~after raising the weapon)
game.set_episode_start_time(10)

# Makes the window appear (turned on by default)
game.set_window_visible(True)
Ejemplo n.º 4
0
# Sets resolution. Default is 320X240
game.set_screen_resolution(ScreenResolution.RES_640X480)

# Sets the screen buffer format. Not used here but now you can change it. Defalut is CRCGCB.
game.set_screen_format(ScreenFormat.RGB24)

# Sets other rendering options
'''
game.set_render_hud(False)
game.set_render_crosshair(False)
game.set_render_weapon(True)
game.set_render_decals(False)
game.set_render_particles(False)
'''
# Adds buttons that will be allowed.
game.add_available_button(Button.MOVE_LEFT)
game.add_available_button(Button.MOVE_RIGHT)
game.add_available_button(Button.ATTACK)

# Adds game variables that will be included in state.
game.add_available_game_variable(GameVariable.AMMO2)

# Causes episodes to finish after 200 tics (actions)
game.set_episode_timeout(200)

# Makes episodes start after 10 tics (~after raising the weapon)
game.set_episode_start_time(10)

# Makes the window appear (turned on by default)
game.set_window_visible(True)
game.set_screen_format(ScreenFormat.RGBA32)
# Whether to render the HUD. (H)eads (U)p (D)isplay is the UI that displays all the vital info of the agent, such as ammo and health
game.set_render_hud(True)
# Whether to render the cross-hair
game.set_render_crosshair(True)
# Whether to render the weapon
game.set_render_weapon(True)
# Whether to render the decals, which are the materials projected on existing surfaces. An example is the bullet impact markers
game.set_render_decals(True)
# Whether to render the particles, which form effects like the muzzle smoke after bullet shots
game.set_render_particles(True)

####################################################################################################
# Add Buttons
####################################################################################################
"""
We can add specific buttons in the following manner--
game.add_available_button(Button.MOVE_LEFT)
However, there are many buttons that are available and a vast amounts of things can be done in the game
For example, move left/move right/duck/drop weapon/select a particular weapon etc.
To see the whole list, we can use the following command--
print(dir(Button))
For now, we will only add buttons for moving and shooting
"""
# Add button to move left
game.add_available_button(Button.MOVE_LEFT)
# Add button to move right
game.add_available_button(Button.MOVE_RIGHT)
# Add button to move front
game.add_available_button(Button.MOVE_FORWARD)
# Add button to move back
Ejemplo n.º 6
0
# If load_config is used in-code configuration will work. Note that the most recent changes will add to previous ones.
#game.load_config("../../examples/config/basic.cfg")

# Sets path to vizdoom engine executive which will be spawned as a separate process. Default is "./vizdoom".
#game.set_vizdoom_path("../../bin/vizdoom")
game.set_doom_game_path("scenarios/freedoom2.wad")
game.set_doom_scenario_path("scenarios/basic.wad")
game.set_doom_map("map01")
game.set_screen_resolution(ScreenResolution.RES_320X240)
game.set_screen_format(ScreenFormat.RGB24)
game.set_render_hud(False)
game.set_render_crosshair(False)
game.set_render_weapon(True)
game.set_render_decals(False)
game.set_render_particles(False)
game.add_available_button(Button.TURN_LEFT_RIGHT_DELTA)
game.add_available_button(Button.ATTACK)
game.add_available_game_variable(GameVariable.AMMO2)
game.add_available_game_variable(GameVariable.ATTACK_READY)
game.set_episode_timeout(200)
game.set_episode_start_time(10)
game.set_window_visible(True)
game.set_sound_enabled(False)
game.set_living_reward(-1)
game.set_mode(Mode.PLAYER)
game.init()

# Define some actions. Each list entry corresponds to declared buttons:
# MOVE_LEFT, MOVE_RIGHT, ATTACK
# 5 more combinations are naturally possible but only 3 are included for transparency when watching.
#actions = [[True,False,False],[False,True,False],[False,False,True]]
Ejemplo n.º 7
0
# Sets resolution. Default is 320X240
# game.set_screen_resolution(ScreenResolution.RES_640X480)

# Sets the screen buffer format. Not used here but now you can change it. Defalut is CRCGCB.

# Sets other rendering options
game.set_render_hud(False)
game.set_render_crosshair(False)
game.set_render_weapon(True)
game.set_render_decals(False)
game.set_render_particles(False)

# Adds buttons that will be allowed.
# game.add_available_button(Button.MOVE_LEFT)
# game.add_available_button(Button.MOVE_RIGHT)
game.add_available_button(Button.MOVE_FORWARD)
game.add_available_button(Button.TURN_LEFT)
game.add_available_button(Button.TURN_RIGHT)
# game.add_available_button(Button.TURN180)
# game.add_available_button(Button.ATTACK)
game.add_available_button(Button.USE)

# game.add_available_button(Button.ATTACK)

# Adds game variables that will be included in state.
game.add_available_game_variable(GameVariable.AMMO2)

# Causes episodes to finish after 200 tics (actions)
game.set_episode_timeout(5000)

# Makes episodes start after 10 tics (~after raising the weapon)