Genetic Alogorithm

Click on the canvas to place walls




Select Sample Size


Frames:


Generation:

The Model

Class for Rocket Object

Class for DNA Object

Class for Population Object

The Explanation

For each geneartion, there is an array called rockets, storing the population size of rocket objects,for each rocket object, there is also a dna object as a property of a single rocket. The dna object is an array of randomize vectors driving every rocket's move in every frame. When a geneartion dies, that is the time when frame reach to 400 by default(will increase as the number of walls increasing), the fitting of each rocket will be calculated. In this case,the one with the shortest distance to the target will have the greatest fitness. Next step is to use the fitness information to generate dna objects for the next geneartion rockets, we also include a small chance of mutation. The new geneartion we get will be more likely to follow their highest fitness parents' path in previous geneartion.