-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.py
46 lines (39 loc) · 1.23 KB
/
test.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
# Simple env test.
import json
import select
import time
import logging
import os
import aicrowd_helper
import gym
import minerl
import coloredlogs
coloredlogs.install(logging.DEBUG)
# All the evaluations will be evaluated on MineRLObtainDiamond-v0 environment
MINERL_GYM_ENV = os.getenv('MINERL_GYM_ENV', 'MineRLObtainDiamond-v0')
MINERL_MAX_EVALUATION_EPISODES = int(os.getenv('MINERL_MAX_EVALUATION_EPISODES', 5))
def main():
"""
This function will be called for training phase.
"""
# Sample code for illustration, add your code below to run in test phase.
# Load trained model from train/ directory
env = gym.make(MINERL_GYM_ENV)
actions = [env.action_space.sample() for _ in range(10)]
xposes = []
for _ in range(MINERL_MAX_EVALUATION_EPISODES):
obs = env.reset()
done = False
netr = 0
while not done:
random_act = env.action_space.noop()
random_act['camera'] = [0, 0.3]
random_act['back'] = 0
random_act['forward'] = 1
random_act['jump'] = 1
random_act['attack'] = 1
obs, reward, done, info = env.step(random_act)
netr += reward
env.close()
if __name__ == "__main__":
main()