Genetic Algorithm

click on the image below to view the live page

Genetic Algorithm

Overview

This program uses a base genetics class that generates bit-based chromosomes to create grids of moving pixel patterns called hue grids. Each chromosome contains bits for color range, pattern type, and cell size. These bits then are used to make up a virtual chromosome which can be mutated by flipping a bit, cut in half and spliced with the chromosome of another hue grid, or replaced by a more fit grid. An array of nine of these grids fills the canvas, and forms the first generation. From here, hovering over a grid and typing "+" raises it's fitness value and typing "-" lowers it. Then, a new generation can be bred from the most fit individuals, which may be repeated until the user is happy with the generational results.

Tools and Technologies

This project was created with JavaScript using p5.js libraries.

Challenges

The biggest challenges with this project came from counting bits, as to create a chromosome you have to keep track of each bit and have the calculated total stay updated for each new piece of genetic information. Also, unexpected patterns resulted in the grids which had their RGB range restricted by the color bits in their chromosome.

View Code