Skip to content

virgs/flappy-bird-ai

Repository files navigation

flappy-bird-ai

screenshot

This project was created for fun and studying purposes. These were the mains goals behind it:

  1. Use the Reactive Message Orientation Object Orientation. A paradigm I conceived to try to reflect Reactive System design in a OO level to get the hang of it and get used to the difficulties that may occur. To do this, I elaborated two ground rules:

    • Message oriented object communication: no public methods. Every communication has to be through a message mechanism (Event emitters) and serializable objects (dto, vo, and others). Objects are not aware of each other.
    • Stateless messages: the messages should include every information it needs, so the receivers process them accordingly.
  2. Study NeuroEvolutionary algorithms. A combination of Neural Network and Genetic Algorithms. The idea is to find a mathematical function that receives inputs (bird y position, the closest pipe gap x position, the closest pipe gap y position) and results in a single output (should jump?). After that, select the best citizens of every generation and create a new generation based exclusively on this and operations such as crossover and mutations.

  3. Study Reinforcement Learning (q-learning). An agent (i.e. the bird) takes in a state and a reward from the environment, and based on these variables, the agent chooses the optimal action (flap/not to flap).

  4. Study Simulated annealing. Simulated_annealing is a metaheuristic to approximate global optimization in a large search space for an optimization problem.

  5. Have fun. Yay.

If you want to, you can watch it live or/and defy the AI. I should warn you, it's not a good idea.

Remember to control the BLUE one (press SPACE BAR to jump and ESC to reinitialize round). Feel free to mess around with the url query params (Defaults to: mutationRate=0.01&populationPerGeneration=1500&relativeSelectedPopulationPerGeneration=0.01&qBirdsNumber=100)

Preview