https://github.com/ParkGyeongTae/dqn-atari-breakout/tree/main/1_cartpole-v1-example
### Step 1) 아나콘다 가상환경 만들기
- conda create -n py37 python=3.7
### Step 2) 가상환경 접속
- conda activate py37
### Step 3) 라이브러리 설치
- pip install gym==0.23.1
- pip install pygame==2.1.2
3_cartpole-v1-step.py
import gym
# import random
env = gym.make('CartPole-v1')
observation = env.reset()
action = env.action_space.sample()
# action = random.randrange(0, 2)
step = env.step(action)
print('observation : ', observation)
print('action : ', action)
print('step : ', step)
python 3_cartpole-v1-step.py
python 3_cartpole-v1-step.py
python 3_cartpole-v1-step.py
python 3_cartpole-v1-step.py
'''
import gym
env = gym.make('CartPole-v1')
# 에피소드 시작
observation = env.reset()
# 임의의 행동 실행
action = env.action_space.sample()
# step : action을 실행했을 때의 결과 (observation, reward, done, info)
step = env.step(action)
print('first_observation : ', first_observation)
print('action : ', action)
print('step : ', step)
# 결과
# first_observation : [0.03486872 0.04418433 -0.00933439 0.02904002]
# action : 0
# step : (array([ 0.0357524 , -0.15080252, -0.00875359, 0.3187633 ], dtype=float32), 1.0, False, {})
'''
'Programming Language > Python' 카테고리의 다른 글
[Python] 강화학습 예제, CartPole-v1 게임 조건 확인하기 (0) | 2022.04.22 |
---|---|
[Python] 강화학습 예제, CartPole-v1 에피소드(episode) 경험해보기 (0) | 2022.04.22 |
[Python] 강화학습, CartPole-v1 행동(action) 알아보기 (0) | 2022.04.22 |
[Python] 강화학습 CartPole-v0 첫 관찰값 출력하는 방법 (0) | 2022.04.22 |
[Python] 강화학습 CartPole-v0을 실행해보자 (with python 3.7) (0) | 2022.04.22 |