All Projects → ivanseidel → Iamdinosaur

ivanseidel / Iamdinosaur

Licence: mit
🦄 An Artificial Inteligence to teach Google's Dinosaur to jump cactus

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Iamdinosaur

Ai Programmer
Using artificial intelligence and genetic algorithms to automatically write programs. Tutorial: http://www.primaryobjects.com/cms/article149
Stars: ✭ 948 (-65.74%)
Mutual labels:  artificial-intelligence, genetic-algorithm, genome
Geneticsharp
GeneticSharp is a fast, extensible, multi-platform and multithreading C# Genetic Algorithm library that simplifies the development of applications using Genetic Algorithms (GAs).
Stars: ✭ 813 (-70.62%)
Mutual labels:  artificial-intelligence, genetic-algorithm
Solid
🎯 A comprehensive gradient-free optimization framework written in Python
Stars: ✭ 546 (-80.27%)
Mutual labels:  artificial-intelligence, genetic-algorithm
Construct
JavaScript Digital Organisms simulator
Stars: ✭ 17 (-99.39%)
Mutual labels:  artificial-intelligence, genetic-algorithm
Artificial Intelligence
Awesome Artificial Intelligence Projects
Stars: ✭ 330 (-88.07%)
Mutual labels:  artificial-intelligence, genetic-algorithm
Pagmo2
A C++ platform to perform parallel computations of optimisation tasks (global and local) via the asynchronous generalized island model.
Stars: ✭ 540 (-80.48%)
Mutual labels:  artificial-intelligence, genetic-algorithm
Car Simulator
Autonomous car simulator (based on JavaScript & WebGL) implemented by fuzzy control system, genetic algorithm and particle swarm optimization.
Stars: ✭ 335 (-87.89%)
Mutual labels:  artificial-intelligence, genetic-algorithm
Machine Learning Flappy Bird
Machine Learning for Flappy Bird using Neural Network and Genetic Algorithm
Stars: ✭ 1,683 (-39.18%)
Mutual labels:  artificial-intelligence, genetic-algorithm
Radiate
Radiate is a parallel genetic programming engine capable of evolving solutions to many problems as well as training learning algorithms.
Stars: ✭ 65 (-97.65%)
Mutual labels:  artificial-intelligence, genetic-algorithm
Notebooks
Some notebooks
Stars: ✭ 53 (-98.08%)
Mutual labels:  artificial-intelligence, genetic-algorithm
Jenetics
Jenetics - Genetic Algorithm, Genetic Programming, Evolutionary Algorithm, and Multi-objective Optimization
Stars: ✭ 616 (-77.74%)
Mutual labels:  artificial-intelligence, genetic-algorithm
Scikit Opt
Genetic Algorithm, Particle Swarm Optimization, Simulated Annealing, Ant Colony Optimization Algorithm,Immune Algorithm, Artificial Fish Swarm Algorithm, Differential Evolution and TSP(Traveling salesman)
Stars: ✭ 2,791 (+0.87%)
Mutual labels:  artificial-intelligence, genetic-algorithm
Csb Ai Starter
Starter Bot for Codingame's Coders Strike Back AI Challenge (Simulation Engine + Random Search)
Stars: ✭ 32 (-98.84%)
Mutual labels:  artificial-intelligence, genetic-algorithm
Mlkit
A simple machine learning framework written in Swift 🤖
Stars: ✭ 144 (-94.8%)
Mutual labels:  artificial-intelligence, genetic-algorithm
Java
Java Projects
Stars: ✭ 24 (-99.13%)
Mutual labels:  dino, google-dinosaur
tiny gp
Tiny Genetic Programming in Python
Stars: ✭ 58 (-97.9%)
Mutual labels:  genetic-algorithm
GDINA
GDINA
Stars: ✭ 23 (-99.17%)
Mutual labels:  dino
async-genetic
A blazing fast parameters optimiser by genetic algorithm
Stars: ✭ 18 (-99.35%)
Mutual labels:  genetic-algorithm
GeneticAlgorithmForFeatureSelection
Search the best feature subset for you classification mode
Stars: ✭ 82 (-97.04%)
Mutual labels:  genetic-algorithm
Articutapi
API of Articut 中文斷詞 (兼具語意詞性標記):「斷詞」又稱「分詞」,是中文資訊處理的基礎。Articut 不用機器學習,不需資料模型,只用現代白話中文語法規則,即能達到 SIGHAN 2005 F1-measure 94% 以上,Recall 96% 以上的成績。
Stars: ✭ 252 (-90.89%)
Mutual labels:  artificial-intelligence

IAMDinosaur

IAMDinosaur

A simple artificial intelligence to teach Google Chrome's offline dinosaur to jump cactus, using Neural Networks and a simple Genetic Algorithm.

Watch this video to see it in action, and learn how it works: Artificial Intelligence with Google's Dinosaur

Installation

  1. Install Node.js on your computer.

  2. Clone/download this folder to your computer.

  3. run npm install within this folder

  4. Open Chrome's dinosaur game and put aside the terminal (It MUST be on the same screen) (Tip: go to developer tools, and under network, set to offline )

  5. run node index within this folder. If the game was located, it will move the cursor of the mouse to the origin of the floor of the dino. Press s key in the terminal to start learning.

How does it work

We have 3 different inputs read from the pixels of the screen:

  1. Distance from the next cactus
  2. Length of the next cactus
  3. Speed of the current cactus

We have also, one output with 3 possible states:

  1. output < 0.45: Press DOWN key
  2. output > 0.55: Press UP key
  3. default: Release both keys

Genetic Algorithm

Each Generation consists of 12 neural networks (Genomes).

Each genome is tested with the game, by constantly mapping the read inputs from the game to the inputs of the neural network, and by getting the output/activation from the network and applying to the keys of the keyboard.

While testing each genome, we keep track of it's "fitness" by counting jumped cactus in the game.

When an entire generation is completed, we remove the worst genomes until achieving N genomes. With those N genomes, we then select two randomly, and cross-over their values/configurations. After that, we apply random mutations in the values/configurations of the Neural Network, creating a new genome.

We do the cross-over/mutation until we get 12 genomes again, and repeat it constantly.

Implementation

All the implementation was done using Node.js, with Synaptic (Neural Network library), and RobotJs (a library to read pixels and simulate key presses).

There are a few files in the project:

  • index.js: It tight all things together.

  • Scanner.js: Basic abstraction layer above RobotJs library that reads the screen like ray tracing. Also have some utilities functions.

  • UI.js: Global scope for the UI management. It initializes and also updates the screen on changes.

  • GameManipulator.js: Has all the necessary code to read sensors, and apply outputs to the game. Is also responsible for computing points, getting the game state and triggering callbacks/listeners to real implementation.

  • Learner.js: It is the core implementation of the Genetic Algorithm. This is where "magic" happens, by running generations, doing "natural" selection, cross-over, mutation...

How to: Load a genome

  1. Make sure Genome is inside genomes folder with a .json extension
  2. Run the program
  3. Click the list in the terminal
  4. Navigate up/down to the wanted file
  5. Press enter (then, to start, press s)

Some shortcuts

  1. Run the program
  2. Press o to save the generation
  3. Press ´escape´, ´q´ or C-c to finish the process

Be aware of a game bug

The dino game has a anoying bug: It starts to "drift" to the right with time making the dino to be wrong offseted from the origin of the game. That, makes the program to read the dino as a cactus, since it is the same color.

You can fix that by continuously refreshing the page, or, by pasting this code inside the console in the element inspector:

// Make sure the dino does not drift to the right
setInterval(function (){Runner.instance_.tRex.xPos = 21}, 2000)

Development guidelines

Please, follow the Node.js style guide from Felix. It is not complex, and has a great simple pattern for things.

Credits

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].