This 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 ASAP. The old version of this project is written in C++. Now it has been rewritten using Python for a user-friendly GUI and the simplicity in the implementations of algorithms.
We use two metrics to evaluate the performance of an AI:
- Success Rate: Rate of success (i.e., the map is filled with the snake's bodies) after playing the game for N times.
- Average Steps: Average steps the snake has taken to success.
Test results (N=1000):
Solver | Demo | Success Rate | Average Steps |
---|---|---|---|
Hamilton | 100.0% | 1776 | |
Greedy | 27.4% | 1575 |
Requirements: Python 3.5+ with Tkinter installed.
$ pip3 install -r requirements.txt
$ python3 run.py
Run unit tests:
$ python3 -m pytest -v
See the LICENSE file for license rights and limitations.