Python으로 배우는 Gymnasium 기반 Reinforcement Learning
Fouad Trad
Machine Learning Engineer

CartPole:
에이전트가 움직이는 카트 위 막대를 균형 잡음

MountainCar: 에이전트가 가파른 언덕을 오름

FrozenLake:
구멍이 있는 얼어붙은 호수를 탐색

Taxi:
승객을 태우고 하차시킴


import gymnasium as gymenv = gym.make('CartPole', render_mode='rgb_array')state, info = env.reset(seed=42) print(state)
[-0.04405273 0.0242996 -0.04377224 -0.01767325]
import matplotlib.pyplot as plt state_image = env.render() plt.imshow(state_image)plt.show()

import matplotlib.pyplot as pltdef render(): state_image = env.render() plt.imshow(state_image) plt.show()# 함수 호출 render()

action = 1
state, reward, terminated, truncated, info = env.step(action)
action = 1 state, reward, terminated, _, _ = env.step(action)print("State: ", state) print("Reward: ", reward) print("Terminated: ", terminated)
State: [-0.04356674 0.22002107 -0.0441257 -0.3238392 ]
Reward: 1.0
Terminated: False
while not terminated:
action = 1 # Move to the right
state, reward, terminated, _, _ = env.step(action)
render()

Python으로 배우는 Gymnasium 기반 Reinforcement Learning