-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathvizdoom_wrapper.py
64 lines (43 loc) · 1.63 KB
/
vizdoom_wrapper.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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
from .base.abwrapper import ActionWrapper
class VizdoomWrapper(ActionWrapper):
def __init__(self):
self.move_number = 0
attack = [1, 0, 0, 0, 0, 0, 0, 0]
use = [0, 1, 0, 0, 0, 0, 0, 0]
move_forward = [0, 0, 1, 0, 0, 0, 0, 0]
move_backward = [0, 0, 0, 1, 0, 0, 0, 0]
move_right = [0, 0, 0, 0, 1, 0, 0, 0]
move_left = [0, 0, 0, 0, 0, 1, 0, 0]
turn_right = [0, 0, 0, 0, 0, 0, 1, 0]
turn_left = [0, 0, 0, 0, 0, 0, 0, 1]
self.actions = [attack, use, move_forward, move_backward,
move_right, move_left, turn_right, turn_left]
self.action_indices = range(len(self.actions))
def is_action_done(self):
return True
def reset(self):
self.move_number = 0
def get_actions(self):
return self.action_indices
def get_excluded_actions(self, obs):
return []
def get_action(self, action_idx, obs):
return self.actions[action_idx]
class VizdoomHealthGatheringWrapper(ActionWrapper):
def __init__(self):
self.move_number = 0
move_forward = [0, 0, 1, 0, 0, 0, 0, 0]
turn_left = [0, 0, 0, 0, 0, 0, 0, 1]
turn_right = [0, 0, 0, 0, 0, 0, 1, 0]
self.actions = [move_forward, turn_right, turn_left]
self.action_indices = range(len(self.actions))
def is_action_done(self):
return True
def reset(self):
self.move_number = 0
def get_actions(self):
return self.action_indices
def get_excluded_actions(self, obs):
return []
def get_action(self, action_idx, obs):
return self.actions[action_idx]