-
-
Notifications
You must be signed in to change notification settings - Fork 404
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Former-commit-id: ce8334d
- Loading branch information
Showing
12 changed files
with
204 additions
and
110 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,62 +1,84 @@ | ||
#!/usr/bin/python | ||
#!/usr/bin/env python | ||
|
||
from __future__ import print_function | ||
from vizdoom import * | ||
from random import choice | ||
from time import sleep | ||
|
||
game = DoomGame() | ||
|
||
game.set_vizdoom_path("../../bin/vizdoom") | ||
|
||
# Use CIG example config or Your own. | ||
# Use CIG example config or your own. | ||
game.load_config("../../examples/config/cig.cfg") | ||
|
||
# Select game and map You want to use. | ||
# Select game and map you want to use. | ||
game.set_doom_game_path("../../scenarios/freedoom2.wad") | ||
#game.set_doom_game_path("../../scenarios/doom2.wad") # Not provided with environment due to licences | ||
|
||
game.set_doom_map("map01") # Limited deathmatch. | ||
#game.set_doom_map("map02") # Full deathmatch. | ||
|
||
# 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 10.0 " | ||
# 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 AI. | ||
game.add_game_args("+name AI") | ||
# 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") | ||
|
||
|
||
# Multiplayer requires the use of asynchronous modes, but when playing only with bots, synchronous modes can also be used. | ||
game.set_mode(Mode.PLAYER) | ||
game.set_mode(Mode.ASYNC_PLAYER) | ||
|
||
# game.set_window_visible(false) | ||
# game.set_window_visible(False) | ||
|
||
game.init() | ||
|
||
# Three example sample actions | ||
actions = [[1,0,0,0,0,0,0,0,0],[0,1,0,0,0,0,0,0,0],[0,0,1,0,0,0,0,0,0]] | ||
|
||
# Add bots (file examples/bots.cfg must be placed in the same directory as the Doom executable file). | ||
bots_number = 7 | ||
for i in range(bots_number): | ||
game.send_game_command("addbot") | ||
# Play with this many bots | ||
bots = 7 | ||
|
||
# Run this many episodes | ||
episodes = 10 | ||
|
||
for i in range(episodes): | ||
|
||
print("Episode #" + str(i+1)) | ||
|
||
# Add specific number of bots | ||
# (file examples/bots.cfg must be placed in the same directory as the Doom executable file, | ||
# edit this file to adjust bots). | ||
game.send_game_command("removebots") | ||
for i in range(bots): | ||
game.send_game_command("addbot") | ||
|
||
# Play until the game (episode) is over. | ||
while not game.is_episode_finished(): | ||
|
||
if game.is_player_dead(): | ||
# Use this to respawn immediately after death, new state will be available. | ||
game.respawn_player() | ||
|
||
# Or observe the game until automatic respawn. | ||
#game.advance_action(); | ||
#continue; | ||
|
||
# Play until the game (episode) is over. | ||
while not game.is_episode_finished(): | ||
s = game.get_state() | ||
# Analyze the state. | ||
|
||
if game.is_player_dead(): | ||
# Use this to respawn immediately after death, new state will be available. | ||
game.respawn_player() | ||
game.make_action(choice(actions)) | ||
# Make your action. | ||
|
||
# Or observe the game until automatic respawn. | ||
#game.advance_action(); | ||
#continue; | ||
print("Frags:", game.get_game_variable(GameVariable.FRAGCOUNT)) | ||
|
||
s = game.get_state() | ||
# Analyze the state. | ||
print("Episode finished.") | ||
print("************************") | ||
|
||
game.make_action(choice(actions)) | ||
# Make your action. | ||
# Starts a new episode. All players have to call new_episode() in multiplayer mode. | ||
game.new_episode() | ||
|
||
print("Frags:", game.get_game_variable(GameVariable.FRAGCOUNT)) | ||
|
||
game.close() |
Oops, something went wrong.