App下載

Python破解Flappy Bird游戲

猿友 2018-08-06 18:27:50 瀏覽數(shù) (3942)
反饋

本文轉載至知乎ID:Charles(白露未晞)知乎個人專欄

下載W3Cschool手機App,0基礎隨時隨地學編程>>戳此了解

導語

昨天在看GitHub上深度學習方面stars較高的開源項目,于是發(fā)現(xiàn)了這個有趣的內容:

使用深度強化學習破解Flappy Bird游戲(深度Q-學習)。


相關文件

百度網(wǎng)盤下載鏈接: https://pan.baidu.com/s/19LgDHq0V3IpE1K5sfuug2g

密碼: tqus


參考文獻

內容主要參考自GitHub開源項目:

Using Deep Q-Network to Learn How To Play Flappy Bird

鏈接:

https://github.com/yenchenlin/DeepLearningFlappyBird


原理簡介

此項目參考了深度增強學習中的深度Q學習算法,并表明了此學習算法可以推廣到破解Flappy Bird游戲當中。也就是說,項目是利用了Q-learning的變體進行訓練的,其輸入是原始像素輸出是估計之后行動的數(shù)值函數(shù)。

PS:

若對深度強化學習感興趣,公眾號相關文件中也提供了一篇名為Demystifying Deep Reinforcement Learning的論文供大家學習,這也是原作者強烈推薦的論文。

網(wǎng)絡架構:

在此之前的預處理為:

(1)灰度化圖像;

(2)圖像大小調整為80×80;

(3)每4幀畫面堆疊成一個80x80x4輸入數(shù)組。

網(wǎng)絡最終輸出結果為2×1的矩陣,用以決定小鳥是否行動。(也就是是否按屏幕咯~~~)

測試環(huán)境

電腦系統(tǒng):Win10

Python版本:3.5.4

Python相關第三方庫:

TensorFlow_GPU版本:1.4.0

Pygame版本:1.9.3

OpenCV-Python版本:3.3.0

具體配置細節(jié)請參考相關網(wǎng)絡文檔?。?!


運行演示

命令行窗口進入DeepLearningFlappyBird文件夾輸入py -3.5 deep_q_network.py回車運行即可:

結果如下:

更多參考文獻

(1) Mnih Volodymyr, Koray Kavukcuoglu, David Silver, Andrei A. Rusu, Joel Veness, Marc G. Bellemare, Alex Graves, Martin Riedmiller, Andreas K. Fidjeland, Georg Ostrovski, Stig Petersen, Charles Beattie, Amir Sadik, Ioannis Antonoglou, Helen King, Dharshan Kumaran, Daan Wierstra, Shane Legg, and Demis Hassabis. Human-level Control through Deep Reinforcement Learning. Nature, 529-33, 2015.

(2) Volodymyr Mnih, Koray Kavukcuoglu, David Silver, Alex Graves, Ioannis Antonoglou, Daan Wierstra, and Martin Riedmiller. Playing Atari with Deep Reinforcement Learning. NIPS, Deep Learning workshop.

(3)Kevin Chen. Deep Reinforcement Learning for Flappy Bird Report | Youtube result.

鏈接:

https://youtu.be/9WKBzTUsPKc

(4)https://github.com/sourabhv/FlapPyBird

(5)https://github.com/asrivat1/DeepLearningVideoGames

0 人點贊