Giter Club home page Giter Club logo

shohan-pherones / snake-game-self-played Goto Github PK

View Code? Open in Web Editor NEW
12.0 1.0 0.0 621 KB

This is a self-played snake game that uses genetic algorithm and neural network to learn and improve its gameplay over time. The game is built using the p5.js library for graphics and user interface, and the tensorflow.js and neataptic libraries for machine learning.

Home Page: https://snake-game-self-played.netlify.app

HTML 0.03% JavaScript 99.97% CSS 0.01%
artificial-intelligence-algorithms artificial-neural-networks genetic-algorithm neat-algorithm neataptic neural-network neuron neuron-simulations nn p5js

snake-game-self-played's Introduction

Self-Played Snake Game with Genetic Algorithm and Neural Network

This is a self-played snake game that uses genetic algorithm and neural network to learn and improve its gameplay over time. The game is built using the p5.js library for graphics and user interface, and the tensorflow.js and neataptic libraries for machine learning.

Getting Started

To run the game on your local machine, follow these steps:

  1. Clone the repository: git clone https://github.com/shohan-pherones/snake-game-self-played.git
  2. Start the game

How it Works

The self-played snake game is designed to learn and improve its gameplay over time. This is achieved using a combination of genetic algorithm and neural network.

The genetic algorithm works by evolving the snake's gameplay over multiple generations. It does this by selecting the fittest individuals from each generation and using them to create the next generation of snakes. The fitness of each individual is determined by how well they perform in the game, such as how long they survive and how many points they score. By selecting the fittest individuals, the algorithm ensures that the best traits of the snakes are passed on to the next generation.

The neural network is used to control the movement of the snake. It takes in input from the game state, such as the position of the snake and the location of the food, and outputs the direction for the snake to move. The network is trained using a combination of supervised and reinforcement learning techniques, with the goal of maximizing the snake's score and survival time. By adjusting the weights and biases of the network based on the results of each game, the network becomes more efficient at controlling the snake's movements over time.

Overall, the combination of genetic algorithm and neural network allows the self-played snake game to learn and adapt to different game scenarios, and ultimately, improve its gameplay over time.

Acknowledgements

This project wouldn't have been possible without the following libraries and resources:

  • p5.js for graphics and user interface
  • TensorFlow.js for machine learning capabilities
  • Neataptic for implementing the neural network
  • SnakeAI for providing inspiration and guidance in creating the genetic algorithm

I would like to thank the developers of these libraries for making their tools available to the public and allowing me to build upon their work. Additionally, I would like to express my gratitude to the creator of SneakAI for providing a valuable resource and inspiring me to create this project.

I also want to thank the community for their support and feedback. If you have any questions or suggestions, feel free to join our Discord server and say hello!

Conclusion

In conclusion, this project has demonstrated the power of combining genetic algorithm and neural network to create a self-played snake game that learns and improves over time. By evolving the gameplay over multiple generations, the game becomes better at handling different scenarios and achieving higher scores. The neural network, powered by TensorFlow.js and Neataptic, enables the game to learn from its mistakes and make better decisions in real-time gameplay.

This project can serve as a starting point for anyone interested in exploring the intersection of machine learning and game development. It provides a framework for designing and implementing machine learning algorithms in games, and can be adapted for use in other games or simulations.

Overall, this project has been a rewarding experience and has opened up new possibilities for the development of intelligent game agents. I hope this project inspires others to explore this fascinating area of research and development.

snake-game-self-played's People

Contributors

shohan-pherones avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.