-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexample.py
32 lines (22 loc) · 1020 Bytes
/
example.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
import numpy as np
import gym
import gym_rubiks_cube
class RandomAgent:
def predict(self, obs):
return np.random.randint(18), None
if __name__ == "__main__":
env = gym.make("RubiksCube-v0")
env.scramble_params = 20 # number of random actions to do for scrambling (called in reset), =0 don't scramble the cube
env.screen_width = 600 # you can reduce the screen size if FPS are too low
env.screen_height = 600
env.cap_fps = 10 # env assumes that you are close to this fps (controls might be weird if it's too far away from it)
env.rotation_step = 5 # higher values makes the animation of rotating take less frames and vice versa, =90 rotations aren't animated
env.max_steps = 50 # number of steps after the environment will return done = False, default None
model = RandomAgent()
obs = env.reset()
done = False
while not done:
env.render()
action, _ = model.predict(obs)
obs, reward, done, _ = env.step(action)
env.close()