-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmax.py
37 lines (31 loc) · 961 Bytes
/
max.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
__author__ = 'max'
#!/usr/bin/env python
from vizdoom import DoomGame
import random
import time
game = DoomGame()
game.load_config("Max/basic.cfg")
#game.load_config('scenario-configs/deadly_corridor.wad')
game.init()
left = [1,0,0 ,0 , 0, 1, 0, 0]
right = [0,1,0 ,0 , 0, 1, 0, 0]
forward = [0,0,1 ,0 , 0, 1, 0, 0]
backward = [0,0,0 ,1 , 0, 1, 0, 0]
jump = [0,0,0 ,0 , 1, 1, 0, 0]
attack=[0,0,0 ,0 , 0, 1, 0, 0]
tleft=[0,0,1 ,0 , 0, 0, 1, 0]
tright=[0,0,1 ,0 , 0, 0, 0, 1]
actions = [left, right, forward, backward, jump, attack, tleft, tright]
episodes = 300
for i in range(episodes):
game.new_episode()
while not game.is_episode_finished():
state = game.get_state()
img = state.screen_buffer
misc = state.game_variables
reward = game.make_action(random.choice(actions))
print("reward:", reward)
time.sleep(0.02)
print(state)
print("Result:", game.get_total_reward())
time.sleep(2)