python制作小蛇_Snake:贪吃蛇游戏 AI 版,通过算法实现让小蛇通过吃豆

Snake

68747470733a2f2f7472617669732d63692e6f72672f63687579616e676c69752f736e616b652e7376673f6272616e63683d6d617374657268747470733a2f2f63692e6170707665796f722e636f6d2f6170692f70726f6a656374732f7374617475732f657736337072317662376565317979692f6272616e63682f6d61737465723f7376673d7472756568747470733a2f2f696d672e736869656c64732e696f2f62616467652f707974686f6e2d332e352b2d626c75652e737667

The project focuses on the artificial intelligence of the Snake game. The snake's goal is to eat the food continuously and fill the map with its bodies as soon as possible. Originally, the project was written in C++. It has now been rewritten in Python for a user-friendly GUI and the simplicity in algorithm implementations.

Experiments

We use two metrics to evaluate the performance of an AI:

Average Length: Average length the snake has grown to (max: 64).

Average Steps: Average steps the snake has moved.

Test results (averaged over 1000 episodes):

Solver

Demo (optimal)

Average Length

Average Steps

solver_hamilton.gif

63.93

717.83

solver_greedy.gif

60.15

904.56

DQN

(experimental)

solver_dqn.gif

24.44

131.69

Installation

Requirements: Python 3.5+ (64-bit) with Tkinter installed.

$ pip3 install -r requirements.txt

# Use -h for more details

$ python3 run.py [-h]

Run unit tests:

$ python3 -m pytest -v

License

See the LICENSE file for license rights and limitations.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值