PyGame Learning Environment
1.0.0
Pygame學習環境(PLE)是一個學習環境,模仿了街機學習環境界面,從而可以快速開始加強Python的學習。 PLE的目的是允許從業者專注於模型和實驗的設計,而不是環境設計。
PLE希望最終建立一個廣闊的遊戲庫。
接受遊戲的PR。
該項目的文檔可以在此處找到。他們目前是WIP。
可用的遊戲可以在文檔中找到。
PLE
實例需要一個遊戲來揭示一組控制方法。要查看所需的方法,請查看ple/games/base.py
。
這是從PLE中的遊戲庫中導入乒乓球的一個示例:
from ple . games . pong import Pong
game = Pong ()
接下來,我們配置和初始化ple:
from ple import PLE
p = PLE ( game , fps = 30 , display_screen = True , force_fps = False )
p . init ()
上面的選項指示PLE使用display_screen
顯示遊戲屏幕,同時允許pygame選擇幀之間的適當延遲時間,以確保使用force_fps
確保30fps。
您可以自由使用PLE的任何代理。在下面,我們創建一個虛構的代理並抓住有效的措施:
myAgent = MyAgent ( p . getActionSet ())
現在,在PLE的幫助下,我們可以通過一定數量的幀與遊戲進行互動:
nb_frames = 1000
reward = 0.0
for f in range ( nb_frames ):
if p . game_over (): #check if the game is over
p . reset_game ()
obs = p . getScreenRGB ()
action = myAgent . pickAction ( reward , obs )
reward = p . act ( action )
就像這樣,我們的代理商與遊戲環境互動。
PLE需要以下依賴性:
克隆回購併與PIP安裝。
git clone https://github.com/ntasfi/PyGame-Learning-Environment.git
cd PyGame-Learning-Environment/
pip install -e .
在使用之前,請在代碼中設置以下內容:
os . putenv ( 'SDL_VIDEODRIVER' , 'fbcon' )
os . environ [ "SDL_VIDEODRIVER" ] = "dummy"
感謝@wooridle。
cd
進入PyGame-Learning-Environment
目錄並運行以下內容:
git pull
如果PLE幫助您的研究,請在您的出版物中引用它。示例Bibtex條目:
@misc{tasfi2016PLE,
author = {Tasfi, Norman},
title = {PyGame Learning Environment},
year = {2016},
publisher = {GitHub},
journal = {GitHub repository},
howpublished = {url{https://github.com/ntasfi/PyGame-Learning-Environment}}
}