-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathenvs_setup.py
171 lines (156 loc) · 5.11 KB
/
envs_setup.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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
import marlo
from marlo import experiments
import gym
from gym import spaces
import gym.wrappers
def start(gamename, width=256, height=192):
global client_width
global client_height
global obs_size
client_width = width
client_height = height
obs_size = client_width * client_height
client_pool = [('127.0.0.1', 10000)]
envparams = {"client_pool": client_pool,
"videoResolution": [client_width, client_height]
}
if gamename == 'MarLo-Attic-v0':
"""
Actions:
'move 0\nturn 0',
'jump 1', 'jump 0',
'move 1', 'move -1',
'pitch 1', 'pitch -1',
'strafe 1', 'strafe -1',
'turn 1', 'turn -1',
'crouch 1', 'crouch 0',
'use 1', 'use 0'
"""
action_select = list(range(15))
elif gamename == 'MarLo-FindTheGoal-v0':
"""
Actions:
'move 0\nturn 0',
'jump 1', 'jump 0',
'move 1', 'move -1',
'pitch 1', 'pitch -1',
'strafe 1', 'strafe -1',
'turn 1', 'turn -1',
'crouch 1', 'crouch 0',
'use 1', 'use 0'
"""
action_select = [0, 3, 4, 5, 6, 9, 10, 13, 14]
elif gamename == 'MarLo-Vertical-v0':
"""
Actions:
'move 0\nturn 0',
'jump 1', 'jump 0',
'move 1', 'move -1',
'pitch 1', 'pitch -1',
'strafe 1', 'strafe -1',
'turn 1', 'turn -1',
'crouch 1', 'crouch 0',
'use 1', 'use 0'
"""
action_select = [0, 3, 4, 9, 10, 13, 14]
elif gamename == 'MarLo-TrickyArena-v0':
"""
Actions:
'move 0\nturn 0',
'jump 1', 'jump 0',
'move 1', 'move -1',
'pitch 1', 'pitch -1',
'strafe 1', 'strafe -1',
'turn 1', 'turn -1',
'crouch 1', 'crouch 0',
'use 1', 'use 0'
"""
action_select = [0, 3, 9, 10]
elif gamename == 'MarLo-Obstacles-v0':
"""
Actions:
'move 0\nturn 0',
'jump 1', 'jump 0',
'move 1', 'move -1',
'pitch 1', 'pitch -1',
'strafe 1', 'strafe -1',
'turn 1', 'turn -1',
'crouch 1', 'crouch 0',
'use 1', 'use 0'
"""
action_select = list(range(15))
elif gamename == 'MarLo-MazeRunner-v0':
"""
Actions:
'move 0\nturn 0',
'jump 1', 'jump 0',
'move 1', 'move -1',
'pitch 1', 'pitch -1',
'turn 1', 'turn -1',
'crouch 1', 'crouch 0',
'attack 1', 'attack 0',
'use 1', 'use 0'
"""
action_select = [0, 1, 2, 3, 7, 8]
elif gamename == 'MarLo-CliffWalking-v0':
"""
Actions:
'move 0\nturn 0',
'move 1', 'move -1',
'jumpmove 1', 'jumpmove -1',
'strafe 1', 'strafe -1',
'jumpstrafe 1', 'jumpstrafe -1',
'turn 1', 'turn -1',
'movenorth 1', 'moveeast 1', 'movesouth 1', 'movewest 1',
'jumpnorth 1', 'jumpeast 1', 'jumpsouth 1', 'jumpwest 1',
'jump 1',
'look 1', 'look -1',
'use 1',
'jumpuse 1'
"""
action_select = [0, 1, 9, 10]
elif gamename == 'MarLo-CatchTheMob-v0':
"""
'move 0\nturn 0',
'move 1', 'move -1',
'jumpmove 1', 'jumpmove -1',
'strafe 1', 'strafe -1',
'jumpstrafe 1', 'jumpstrafe -1',
'turn 1', 'turn -1',
'movenorth 1', 'moveeast 1', 'movesouth 1', 'movewest 1',
'jumpnorth 1', 'jumpeast 1', 'jumpsouth 1', 'jumpwest 1',
'jump 1',
'look 1','look -1',
'use 1',
'jumpuse 1'
"""
action_select = [0, 1, 9, 10, 22]
elif gamename == 'MarLo-Eating-v0':
"""
Actions:
'move 0\nturn 0',
'jump 1','jump 0',
'move 1','move -1',
'pitch 1','pitch -1',
'strafe 1','strafe -1',
'turn 1','turn -1',
'crouch 1', 'crouch 0',
'use 1', 'use 0']
"""
action_select = [0, 3, 9, 10, ]
envparams = {"client_pool": client_pool,
"videoResolution": [320, 240],
"observeHotBar": True
}
else:
action_select = [0, 1, 2, 3, 7, 8] # default
n_actions = len(action_select)
action_space = list(range(n_actions))
# Ensure that you have a minecraft-client running with : marlo-server
# --port 10000
join_tokens = marlo.make(gamename, params=envparams)
assert len(join_tokens) == 1
join_token = join_tokens[0]
global env
env = marlo.init(join_token)
return n_actions, action_space, action_select