a b/examples/legacy/round2_submit.py
1
#!/usr/bin/env python
2
3
import opensim as osim
4
5
from osim.redis.client import Client
6
from osim.env import *
7
import numpy as np
8
import argparse
9
import os
10
11
"""
12
NOTE: For testing your submission scripts, you first need to ensure that redis-server is running in the background
13
and you can locally run the grading service by running this script : https://github.com/crowdAI/osim-rl/blob/master/osim/redis/service.py
14
15
The client and the grading service communicate with each other by pointing to the same redis server.
16
"""
17
18
"""
19
Please ensure that `visualize=False`, else there might be unexpected errors in your submission
20
"""
21
env = RunEnv(visualize=False)
22
client = Client()
23
24
# Create environment
25
observation = client.env_create()
26
27
"""
28
The grader runs N simulations of at most 1000 steps each. We stop after the last one
29
A new simulation start when `clinet.env_step` returns `done==True`
30
and all the simulatiosn end when the subsequent `client.env_reset()` returns a False
31
"""
32
while True:
33
    _action = env.action_space.sample().tolist()
34
    [observation, reward, done, info] = client.env_step(_action)
35
    print(observation)
36
    if done:
37
        observation = client.env_reset()
38
        if not observation:
39
            break
40
41
client.submit()