Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/leoherrmann/autosnek
A snake trying to determine the best possible movements considering growth and survival possibilities
https://github.com/leoherrmann/autosnek
algorithms multithreading snake-game web-workers
Last synced: about 1 month ago
JSON representation
A snake trying to determine the best possible movements considering growth and survival possibilities
- Host: GitHub
- URL: https://github.com/leoherrmann/autosnek
- Owner: LeoHerrmann
- Created: 2020-06-27T13:51:00.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2020-12-05T18:23:36.000Z (about 4 years ago)
- Last Synced: 2023-07-22T14:48:24.617Z (over 1 year ago)
- Topics: algorithms, multithreading, snake-game, web-workers
- Language: JavaScript
- Homepage: https://leoherrmann.github.io/autosnek/
- Size: 198 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: changelog.txt
Awesome Lists containing this project
README
# Autosnek
A snake trying to determine the best possible movements considering growth and survival possibilities## Screenshots
## About
The application is based on the classic snake game in which the player controls the movements of a snake. In order to achieve the highest possible score, the snake needs to eat food. However, each time the snake gets to eat food, it becomes longer, increasing the difficulty of the game. If the snake runs into itself or into a border of the playing field, it dies and the game is over. In this application the snake is controlled automatically using an algorithm. Watching the snake fight for its survival is quite exciting because of its ability to precisely calculate movements which would be too risky for human players to execute.## How it works
Each step the movements bringing the snake closer to the food source are determined. If it is possible for the snake to survive a certain number of steps after one of these movements are executed, it moves towards the food source. Otherwise, another direction is chosen, allowing the snake to continue living for longer. To determine whether a movement will allow the snake to survive, a recursive algorithm is used predicting each possible future movement up to a certain depth. The maximum recursion depth is limited due to processing time resulting in the snake eventually getting into a situation in which it is impossible to come out alive.## Serial vs parallel mode
The application allows choosing between serial and parallel mode. In serial mode the entire code runs on the main thread, whereas in parallel mode the task of determining the survival possibilities is split up and distributed to web workers. The additional time it takes to manage these web workers results in parallel mode actually having considerably longer average processing times than serial mode. However, in situations where many possibilities need to be considered, the advantages of parallel processing become clearly visible and contribute to the maximum processing times being substancially shorter in parallel mode than in serial mode.## Getting started
Since this is a web application, there is no need to install it. You can click [here](https://rahmsauce.github.io/Autosnek/index.html) to try it out or if you want to run it on your local machine, download the repository and open index.html using a web browser. If you become tired of watching, you might want have a look at the [manual version](https://github.com/Rahmsauce/Snek) and try to beat the algorithm.