https://github.com/goktug97/pythonsnake
A Snake Environment to Train AI Algorithms
https://github.com/goktug97/pythonsnake
artificial-intelligence evolution-strategies game genetic-algorithm python reinforcement-learning
Last synced: 4 months ago
JSON representation
A Snake Environment to Train AI Algorithms
- Host: GitHub
- URL: https://github.com/goktug97/pythonsnake
- Owner: goktug97
- License: mit
- Created: 2020-03-01T09:37:07.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2020-03-22T18:25:29.000Z (over 5 years ago)
- Last Synced: 2025-06-25T23:02:02.065Z (4 months ago)
- Topics: artificial-intelligence, evolution-strategies, game, genetic-algorithm, python, reinforcement-learning
- Language: Python
- Size: 4.72 MB
- Stars: 3
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
Python Snake
==========================================A Snake environment to train AIs.

## Requirements
* numpy### Demo GUI
* cv2## Install
```bash
git clone https://github.com/goktug97/PythonSnake
cd PythonSnake
python setup.py install --user
```## Play
``` bash
python-snake
```## Usage
Check [play.py](https://github.com/goktug97/PythonSnake/blob/master/play.py) for an example.
``` python
import snake
import AwesomeAIAlgorithm
import cv2game = snake.Game()
best_ai = AwesomeAIAlgorithm.BestAI()while not game.done:
screen = game.draw(block_size=15)
cv2.imshow('center', screen)
if cv2.waitKey(50) == 27:
break
action = best_ai.eval(game.map, game.snake.head,
game.snake.x_direction,
game.snake.y_direction,
game.apple)
game.step(action)
```