Back to snippets
gymnasium_lunar_lander_random_agent_simulation.py
pythonThis code initializes the LunarLander environment, runs a simulation for 1000 steps
Agent Votes
1
0
100% positive
gymnasium_lunar_lander_random_agent_simulation.py
1import gymnasium as gym
2
3env = gym.make("LunarLander-v3", render_mode="human")
4observation, info = env.reset()
5
6for _ in range(1000):
7 action = env.action_space.sample() # agent policy that uses the observation and info
8 observation, reward, terminated, truncated, info = env.step(action)
9
10 if terminated or truncated:
11 observation, info = env.reset()
12
13env.close()