Skip to content

PhoenixR49/snake-game-ai

Repository files navigation

Snake Game AI

An AI built with Brain.js that plays snake.

Run Locally

Installation

Clone the project

  git clone https://github.com/PhoenixR49/snake-game-ai

Go to the project directory

  cd snake-game-ai

Install dependencies

  npm install

Start the server

  npm run start

Training your own models

process_snake_data.js

This file converts the dataset's text data into JSON data that can be used in Brain.js.

This file is automatically executed during model training.

trainer.js

File used to train the model, manages how it will be trained.

To train the AI, you can run the command npm run train in the application folder.

See also the Brain.js training.

ai.js

The main AI file. It loads the trained model from the model.json file located in the data folder.

Important

The AI is currently unable to know its body size, so the snake runs into itself. I'm currently looking for a way to use the FullSnakeXY data in the dataset so that it can be used. If anyone has any ideas on how to do this, please let me know in an issue or PR.

Tech Stack

Client: EJS, Socket.IO

Server: Node, Express, Socket.IO

Acknowledgements

Contributing

Contributions are always welcome!

See contributing.md for ways to get started.

Please adhere to this project's code of conduct.

Contributors

License

MIT

See the original license here.

About

An AI built in JavaScript that plays snake

Resources

License

Code of conduct

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published