forked from mpSchrader/gym-sokoban
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRandom_Sampling.py
More file actions
34 lines (26 loc) · 883 Bytes
/
Random_Sampling.py
File metadata and controls
34 lines (26 loc) · 883 Bytes
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
import gym
import gym_sokoban
import time
# Before you can make a Sokoban Environment you need to call:
# import gym_sokoban
# This import statement registers all Sokoban environments
# provided by this package
env_name = 'Sokoban-v0'
env = gym.make(env_name)
ACTION_LOOKUP = env.unwrapped.get_action_lookup()
print("Created environment: {}".format(env_name))
for i_episode in range(1):#20
observation = env.reset()
for t in range(100):#100
env.render(mode='human')
action = env.action_space.sample()
# Sleep makes the actions visible for users
time.sleep(1)
observation, reward, done, info = env.step(action)
print(ACTION_LOOKUP[action], reward, done, info)
if done:
print("Episode finished after {} timesteps".format(t+1))
env.render()
break
env.close()
time.sleep(10)