
강화 학습을 위한 API 표준, 다양한 참고 환경 모음 제공

Gymnasium는 OpenAI의 Gym 라이브러리를 유지보수하여 분기(fork)된 라이브러리입니다. Gymnasium 인터페이스는 간단하고 파이써닉하며 일반적인 RL 문제를 표현할 수 있으며, 이전 Gym 환경을 위한 호환성 래퍼를 제공합니다:
import gymnasium as gym
# Initialise the environment
env = gym.make("LunarLander-v3", render_mode="human")
# Reset the environment to generate the first observation
observation, info = env.reset(seed=42)
for _ in range(1000):
# this is where you would insert your policy
action = env.action_space.sample()
# step (transition) through the environment with the action
# receiving the next observation, reward and if the episode has terminated or truncated
observation, reward, terminated, truncated, info = env.step(action)
# If the episode has ended then we can reset to start a new episode
if terminated or truncated:
observation, info = env.reset()
env.close()