Views
No views yet
1from stable_baselines3 import PPO
2import gymnasium as gym
3
4# Load the trained model
5model = PPO.load("lunar_lander_ppo_model")
6
7# Create environment
8env = gym.make('LunarLander-v2', render_mode='human')
9
10# Test the agent
11obs, _ = env.reset()
12for _ in range(1000):
13 action, _ = model.predict(obs, deterministic=True)
14 obs, reward, terminated, truncated, info = env.step(action)
15 if terminated or truncated:
16 obs, _ = env.reset()
17
18env.close()