您的位置:首页 > 移动开发

用Tensorflow训练的AI玩flappy bird小游戏

2017-08-16 21:46 471 查看
原作者的理论介绍文章:

程序员带你一步步分析AI如何玩Flappy Bird
http://www.jianshu.com/p/0a04426ee3ad
本文只介绍如何配置系统玩起来,基于ubuntu 16.04.

1.安装anaconda

下载地址:
https://www.continuum.io/downloads#linux
cd 下载

sudo chmod +x Anaconda3-4.4.0-Linux-x86_64.sh

./Anaconda3-4.4.0-Linux-x86_64.sh

这个是for python3.6的,因为现在的tensorflow版本是for python 3.5的,改成3.5免得有问题:

conda install python=3.5

2.安装opencv

conda install --channel https://conda.anaconda.org/menpo opencv3

3.安装tensorflow

conda install tensorflow

4.安装pygame

conda install --channel https://conda.anaconda.org/kne pygame

5.安装sdl

conda install --channel https://conda.anaconda.org/ufechner sdl

6.运行小鸟游戏

git clone https://github.com/yenchenlin1994/DeepLearningFlappyBird.git
cd DeepLearningFlappyBird

python deep_q_network.py

运行报错:

pygame.image.load('assets/sprites/0.png').convert_alpha(),

pygame.error: File is not a Windows BMP file

不知道什么问题,干脆把png全部另存为bmp,在报错的py文件中也做相应修改。

再运行还是报错:找不到sdl_mixer。

不知道什么问题,直接把程序中的mixer相关语句注释掉即可,鸟死的时候你自己“啊”一声吧。

再运行,就可以看到小鸟自动飞啊飞了:

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: