https://github.com/shsiena/machine-learning-snake
(In Progress) a PyGame implementation of Snake used to train a neural network through genetic learning.
https://github.com/shsiena/machine-learning-snake
game genetic-algorithm machine-learning neural-network pygame snake
Last synced: 7 months ago
JSON representation
(In Progress) a PyGame implementation of Snake used to train a neural network through genetic learning.
- Host: GitHub
- URL: https://github.com/shsiena/machine-learning-snake
- Owner: shsiena
- Created: 2024-04-25T19:59:39.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-06-16T01:25:50.000Z (over 1 year ago)
- Last Synced: 2025-03-01T01:38:18.552Z (7 months ago)
- Topics: game, genetic-algorithm, machine-learning, neural-network, pygame, snake
- Language: Python
- Homepage:
- Size: 65.4 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
## Machine Learning Snake
A recreation of Snake, written in Python using PyGame, with an added implementation of a neural network for deep learning.This project is very much in a work in progress state, with a fully functioning NumPy neural network, however I have approached this problem from a genetic learning approach, which has proved difficult.
I may end up switching this project to a deep Q-learning algorithm if it proves more successful. If I do this, I will likely also transition from NumPy exclusively to PyTorch
#### End Goal
- Train a neural network to successfully play Snake.#### Agent Observations:
- Distance to food in each cardinal direction (+ diagonals)
- Safe distance in each cardinal direction (+ diagonals)#### Network Layers
- Input Layer
- (16 x 1)
- Layer 1
- (16 x 1) Perceptrons
- Activation: Sigmoid
- Layer 2
- (8 x 1) Perceptrons
- Activation: Sigmoid
- Layer 3
- (4 x 1)
- Activation: Softmax