-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlander_test.py
More file actions
29 lines (21 loc) · 778 Bytes
/
lander_test.py
File metadata and controls
29 lines (21 loc) · 778 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
import gym
from gym.envs.box2d import LunarLanderContinuous
from stable_baselines3 import SAC
from stable_baselines3.common.monitor import Monitor
from stable_baselines3.common.vec_env import VecFrameStack, DummyVecEnv
class LunarLanderContinuousDifficult(LunarLanderContinuous):
def step(self, action):
ob, reward, done, info = super().step(action)
ob[2:3] = 0
return ob, reward, done, info
env = LunarLanderContinuousDifficult()
env = DummyVecEnv([lambda:env])
env = VecFrameStack(env, n_stack=3)
model = SAC.load("Lunar_DummyVecEnv.zip")
obs = env.reset()
for i in range(10000):
action, _state = model.predict(obs, deterministic=True)
obs, reward, done, info = env.step(action)
env.render()
if done:
obs = env.reset()