JavaScript Genetic Algorithm example

JavaScript Genetic Algorithm example

Genetic algorithm – In the computer science field of artificial intelligence, a genetic algorithm (GA) is a search heuristic that mimics the process of natural evolution. This heuristic (also sometimes called a metaheuristic) is routinely used to generate useful solutions to optimization and search problems.

Genetic algorithms belong to the larger class of evolutionary algorithms (EA), which generate solutions to optimization problems using techniques inspired by natural evolution, such as inheritance, mutation, selection, and crossover.

There is a simple demonstration of this algorithm below

Click on any cell
with Mouse to check/uncheck the cell
Press and hold CTRL + Mouse Over
to check/uncheck multiple cells

Enter desired image size and press Draw.
You need to enter width of the image in “cells”

Size – width / height of square image that you going to draw
Mutation – value which specifies what values we are going to change randomly on every generation
Precision – how many wrong cells in compared image we are going to tolerate

1. Enter desired size (in cells):

2. Enter algorithm settings:

3. See genetics in action!