All Articles

Week8 Genetic Algorithms

I wonder if the computer can figure out itself how to draw a circle? Maybe by applying a genetic algorithm on it.

Scenario

It’s gonna be a matrix where black & white pixels are randomly placed. The population is the different picture(matrix). They are evolving to have a perfect circle on the canvas.

Phenotype and Genotype

Each individual will be stored as a 2D array, that shows the color of each pixel by 1 or 0.

Fitness Function

The fitness will be calculate by the sum of square distance between black pixels and the center minus the setting goal circle radius.

Mutation and Crossover

A mutation may make a distorted circle perfect, and crossover can combine two unfinished circles with different half.