Skip to main content

snake with ai

Project description

snakai 有AI的贪吃蛇

Upload Python Package

snake is running! our project final goal is to build a snake game driven by Reinforcement Learning.


Setting / 设置

language: Python3

package-name: snakai (snake + ai)

Start / 开始

# create env and active it
python -m venv snakai_env
source snakai_env/bin/activate
# install 
pip install snakai
# or `pip install -e .` in dev mode
# run snake using QLearning based strategy.
run_snake -s qlearning 
# `run_snake -s rule_based` to run in rule-based strategy, or `-s manual` to playing the game...
# `run_snake -h` to see all params

Attention: if you want to run qlearning based strategy, you need train it firstly.
Just go to qlearning-strategy and run the scripts' script to train the model.
Currently, about 13 minutes is needed.

you will see following screen if no exception.


screen by the fantastic ScreenToGif

Progress / 进度

  • draw snake based on curses. 绘制贪吃蛇(控制台) ✅✅✅ 下载了一个示例,照着学习。

    • 完成 package 构建 & 配置上传到 pypi
  • rule-based strategy. 基于规则的AI ✅🔲🔲

    • 完成一个基于规则的策略。目前看比较笨。之前调研的时候发现有用 哈密顿连通图 之类来做,后续可以试下。
    • 另外,还准备试下 A* 算法,之前说好要在博客介绍一下 A* 算法的
  • RL-based strategy. 基于强化学习的AI [little milestone] ✅🔲🔲

    • 目前做了基于 Q-Learning 的策略。具体见 qlearning-strategy.
    • 后续准备优化 & 尝试 Deep Q-Learning
  • unity or some other game-engine driven snake? 基于其他游戏引擎的贪吃蛇? 🔲🔲🔲



  • 2021.08.08: 完成 qlearning 的基础版本。到此,最基础的策略都已经实现了!
  • 2021.01.03: 再次重新组织代码结构,完成了策略逻辑和绘制逻辑的拆分
  • 2019.12.28: 有空重新组织了代码结构,完成了绘制逻辑和状态逻辑的拆分;写了snake游戏的开发关键

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

snakai-1.1.tar.gz (21.2 kB view hashes)

Uploaded Source

Built Distribution

snakai-1.1-py3-none-any.whl (28.9 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page