All Projects → ssusnic → Machine Learning Flappy Bird

ssusnic / Machine Learning Flappy Bird

Licence: mit
Machine Learning for Flappy Bird using Neural Network and Genetic Algorithm

Programming Languages

javascript
184084 projects - #8 most used programming language
HTML
75241 projects

Projects that are alternatives of or similar to Machine Learning Flappy Bird

NeuroEvolution-Flappy-Bird
A comparison between humans, neuroevolution and multilayer perceptrons playing Flapy Bird implemented in Python
Stars: ✭ 17 (-98.99%)
Mutual labels:  genetic-algorithm, flappy-bird, neuroevolution, game-programming, machine-intelligence, ai-tutorial, artificial-evolution
Artificio
Deep Learning Computer Vision Algorithms for Real-World Use
Stars: ✭ 326 (-80.63%)
Mutual labels:  artificial-intelligence, ai, neural-networks
Lightnet
🌓 Bringing pjreddie's DarkNet out of the shadows #yolo
Stars: ✭ 322 (-80.87%)
Mutual labels:  artificial-intelligence, ai, neural-networks
Awesome Artificial Intelligence
A curated list of Artificial Intelligence (AI) courses, books, video lectures and papers.
Stars: ✭ 6,516 (+287.17%)
Mutual labels:  artificial-intelligence, ai, machine-intelligence
Igel
a delightful machine learning tool that allows you to train, test, and use models without writing code
Stars: ✭ 2,956 (+75.64%)
Mutual labels:  artificial-intelligence, neural-networks, machinelearning
Sharpneat
SharpNEAT - Evolution of Neural Networks. A C# .NET Framework.
Stars: ✭ 273 (-83.78%)
Mutual labels:  ai, neural-networks, neuroevolution
Spacy
💫 Industrial-strength Natural Language Processing (NLP) in Python
Stars: ✭ 21,978 (+1205.88%)
Mutual labels:  artificial-intelligence, ai, neural-networks
Fixy
Amacımız Türkçe NLP literatüründeki birçok farklı sorunu bir arada çözebilen, eşsiz yaklaşımlar öne süren ve literatürdeki çalışmaların eksiklerini gideren open source bir yazım destekleyicisi/denetleyicisi oluşturmak. Kullanıcıların yazdıkları metinlerdeki yazım yanlışlarını derin öğrenme yaklaşımıyla çözüp aynı zamanda metinlerde anlamsal analizi de gerçekleştirerek bu bağlamda ortaya çıkan yanlışları da fark edip düzeltebilmek.
Stars: ✭ 165 (-90.2%)
Mutual labels:  artificial-intelligence, ai, neural-networks
Awesome Ai Ml Dl
Awesome Artificial Intelligence, Machine Learning and Deep Learning as we learn it. Study notes and a curated list of awesome resources of such topics.
Stars: ✭ 831 (-50.62%)
Mutual labels:  artificial-intelligence, ai, neural-networks
Construct
JavaScript Digital Organisms simulator
Stars: ✭ 17 (-98.99%)
Mutual labels:  artificial-intelligence, ai, genetic-algorithm
Riceteacatpanda
repo with challenge material for riceteacatpanda (2020)
Stars: ✭ 18 (-98.93%)
Mutual labels:  artificial-intelligence, ai, neural-networks
Echotorch
A Python toolkit for Reservoir Computing and Echo State Network experimentation based on pyTorch. EchoTorch is the only Python module available to easily create Deep Reservoir Computing models.
Stars: ✭ 231 (-86.27%)
Mutual labels:  artificial-intelligence, neural-networks, machinelearning
Atari Model Zoo
A binary release of trained deep reinforcement learning models trained in the Atari machine learning benchmark, and a software release that enables easy visualization and analysis of models, and comparison across training algorithms.
Stars: ✭ 198 (-88.24%)
Mutual labels:  artificial-intelligence, ai, machinelearning
Free Ai Resources
🚀 FREE AI Resources - 🎓 Courses, 👷 Jobs, 📝 Blogs, 🔬 AI Research, and many more - for everyone!
Stars: ✭ 192 (-88.59%)
Mutual labels:  artificial-intelligence, ai, machinelearning
Letslearnai.github.io
Lets Learn AI
Stars: ✭ 33 (-98.04%)
Mutual labels:  artificial-intelligence, ai, machinelearning
Text summurization abstractive methods
Multiple implementations for abstractive text summurization , using google colab
Stars: ✭ 359 (-78.67%)
Mutual labels:  artificial-intelligence, ai, machinelearning
Classic Pool Game
Classic 8 Ball pool game written in JavaScript
Stars: ✭ 177 (-89.48%)
Mutual labels:  ai, genetic-algorithm, html5
Best ai paper 2020
A curated list of the latest breakthroughs in AI by release date with a clear video explanation, link to a more in-depth article, and code
Stars: ✭ 2,140 (+27.15%)
Mutual labels:  artificial-intelligence, ai, machinelearning
Basic reinforcement learning
An introductory series to Reinforcement Learning (RL) with comprehensive step-by-step tutorials.
Stars: ✭ 826 (-50.92%)
Mutual labels:  artificial-intelligence, ai, neural-networks
Ai Programmer
Using artificial intelligence and genetic algorithms to automatically write programs. Tutorial: http://www.primaryobjects.com/cms/article149
Stars: ✭ 948 (-43.67%)
Mutual labels:  artificial-intelligence, ai, genetic-algorithm

Machine Learning for Flappy Bird using Neural Network and Genetic Algorithm

Here is the source code for a HTML5 project that implements a machine learning algorithm in the Flappy Bird video game using neural networks and a genetic algorithm. The program teaches a little bird how to flap optimally in order to fly safely through barriers as long as possible.

The complete tutorial with much more details and demo you can find here:
http://www.askforgametask.com/tutorial/machine-learning-algorithm-flappy-bird

Here you can also watch a short video with a simple presentation of the algorithm:
https://www.youtube.com/watch?v=aeWmdojEJf0

All code is written in HTML5 using Phaser framework and Synaptic Neural Network library for neural network implementation.

Flappy Bird Screenshot

Neural Network Architecture

To play the game, each unit (bird) has its own neural network consisted of the next 3 layers:

  1. an input layer with 2 neurons presenting what a bird sees:

    1) horizontal distance between the bird and the closest gap
    2) height difference between the bird and the closest gap
    
  2. a hidden layer with 6 neurons

  3. an output layer with 1 neuron used to provide an action as follows:

    if output > 0.5 then flap else do nothing
    

Flappy Bird Neural Network

There is used Synaptic Neural Network library to implement entire artificial neural network instead of making a new one from the scratch.

The Main Concept of Machine Learning

The main concept of machine learning implemented in this program is based on the neuro-evolution form. It uses evolutionary algorithms such as a genetic algorithm to train artificial neural networks. Here are the main steps:

  1. create a new population of 10 units (birds) with a random neural network

  2. let all units play the game simultaneously by using their own neural networks

  3. for each unit calculate its fitness function to measure its quality as:

    fitness = total travelled distance - distance to the closest gap
    

    Flappy Bird Fitness

  4. when all units are killed, evaluate the current population to the next one using genetic algorithm operators (selection, crossover and mutation) as follows:

    1. sort the units of the current population in decreasing order by their fitness ranking
    2. select the top 4 units and mark them as the winners of the current population
    3. the 4 winners are directly passed on to the next population
    4. to fill the rest of the next population, create 6 offsprings as follows:
        - 1 offspring is made by a crossover of two best winners
        - 3 offsprings are made by a crossover of two random winners
        - 2 offsprings are direct copy of two random winners
    5. to add some variations, apply random mutations on each offspring.
    
  5. go back to the step 2

Implementation

Requirements

Since the program is written in HTML5 using Phaser framework and Synaptic Neural Network library you need these files:

  • phaser.min.js
  • synaptic.min.js

gameplay.js

The entire game logic is implemented in gameplay.js file. It consists of the following classes:

  • App.Main, the main routine with the following essential functions:

    • preload() to preload all assets
    • create() to create all objects and initialize a new genetic algorithm object
    • update() to run the main loop in which the Flappy Bird game is played by using AI neural networks and the population is evolved by using genetic algorithm
    • drawStatus() to display information of all units
  • TreeGroup Class, extended Phaser Group class to represent a moving barrier. This group contains a top and a bottom Tree sprite.

  • Tree Class, extended Phaser Sprite class to represent a Tree sprite.

  • Bird Class, extended Phaser Sprite class to represent a Bird sprite.

  • Text Class, extended Phaser BitmapText class used for drawing text.

genetic.js

The genetic algorithm is implemented in genetic.js file which consists of the following class:

  • GeneticAlgorithm Class, the main class to handle all genetic algorithm operations. It needs two parameters: max_units to set a total number of units in population and top_units to set a number of top units (winners) used for evolving population. Here are its essential functions:

    • reset() to reset genetic algorithm parameters
    • createPopulation() to create a new population
    • activateBrain() to activate the AI neural network of an unit and get its output action according to the inputs
    • evolvePopulation() to evolve the population by using genetic operators (selection, crossover and mutations)
    • selection() to select the best units from the current population
    • crossOver() to perform a single point crossover between two parents
    • mutation() to perform random mutations on an offspring
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].