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
7_cartpole-v1-observation-action.py
import gym
env = gym.make('CartPole-v1')
observation = env.reset()
print("1 :", observation)
observation, reward, done, info = env.step(0)
# observation, reward, done, info = env.step(1)
print("2 :", observation)
env.close()
python 7_cartpole-v1-observation-action.py
7_cartpole-v1-observation-action.py
import gym
env = gym.make('CartPole-v1')
observation = env.reset()
print("1 :", observation)
observation, reward, done, info = env.step(0)
# observation, reward, done, info = env.step(1)
print("2 :", observation)
observation, reward, done, info = env.step(0)
# observation, reward, done, info = env.step(1)
print("3 :", observation)
observation, reward, done, info = env.step(0)
# observation, reward, done, info = env.step(1)
print("4 :", observation)
env.close()
python 7_cartpole-v1-observation-action.py
'''
import gym
env = gym.make('CartPole-v1')
# 에피소드 실행
observation = env.reset()
# 처음 관찰값
print(observation)
# 0이라는 행동을 실행
observation, reward, done, info = env.step(0)
# 행동 이후 관찰값
print(observation)
env.close()
# 결과
# [0.00967408 0.04968553 -0.01428431 -0.00555329]
# [0.01066779 -0.14522868 -0.01439537 0.28258875]
'''
'Programming Language > Python' 카테고리의 다른 글
[Python] 강화학습, CartPole-v1 기울기값에 따른 행동 변화 (0) | 2022.04.23 |
---|---|
[Python] 강화학습 예제, CartPole-v1 같은 행동 10번 반복 할 때 관찰값 (0) | 2022.04.22 |
[Python] 강화학습 예제, CartPole-v1 게임 조건 확인하기 (0) | 2022.04.22 |
[Python] 강화학습 예제, CartPole-v1 에피소드(episode) 경험해보기 (0) | 2022.04.22 |
[Python] 강화학습 예제, CartPole-v1 step(다음 행동) 알아보기 (0) | 2022.04.22 |