Using Custom Environments – pt.3

Published by onesixx on

https://pythonprogramming.net/custom-environment-reinforcement-learning-stable-baselines-3-tutorial/

(OpenAI의 gym Environment 대신에) 자신의 custom Environment에서 RL을 수행.

어떤 Enviroment를 gym Environment에 맞게 변환해 주면 된다. (말이 쉽지 구현이 까다롭다….)

RL에서 가장 까다로운 2가지
– Environment의 observation을 가져오는 일 (data engineering)
– Agent에 적절한 rewards부여하기

Game = 그 자체가 가장 좋은 Enviroments = 뱀게임 (source)

Python
snake_game.py

위 게임을 gym environment로 변환하기 위해 필요한 구조

Python

“””Custom Environment that follows gym interface”””

Python
snake_customenv.py

defining our action space and observation space.

action space

 4 clear possible actions

Python

observation space

게임이미지 보다는.. 어설프더라도 좀더 구체적인 수치.

뱀머리 위치, 사과 위치, 뱀몸통 위치,

Python

reward

뱀길이

Python

reset()

episode시작시 마다 (steps이 시작하기전에) 호출

Categories: RL

onesixx

Blog Owner

Subscribe
Notify of
guest

0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x