[077a87]: / examples / legacy / round2_submit.py

Download this file

42 lines (33 with data), 1.2 kB

 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
#!/usr/bin/env python
import opensim as osim
from osim.redis.client import Client
from osim.env import *
import numpy as np
import argparse
import os
"""
NOTE: For testing your submission scripts, you first need to ensure that redis-server is running in the background
and you can locally run the grading service by running this script : https://github.com/crowdAI/osim-rl/blob/master/osim/redis/service.py
The client and the grading service communicate with each other by pointing to the same redis server.
"""
"""
Please ensure that `visualize=False`, else there might be unexpected errors in your submission
"""
env = RunEnv(visualize=False)
client = Client()
# Create environment
observation = client.env_create()
"""
The grader runs N simulations of at most 1000 steps each. We stop after the last one
A new simulation start when `clinet.env_step` returns `done==True`
and all the simulatiosn end when the subsequent `client.env_reset()` returns a False
"""
while True:
_action = env.action_space.sample().tolist()
[observation, reward, done, info] = client.env_step(_action)
print(observation)
if done:
observation = client.env_reset()
if not observation:
break
client.submit()