Welcome to UVM's Art & AI Genetic Algorithm!
What is a Genetic Algorith
A genetic algorithm is a tool from computer science originally used for optimization. Genetic algorithms are inspired by darwinian evolution and the process of natural selection. This is done with biological operators such as mutation, crossover, and selection.
Our Genetic Algorithm
Typically, Genetic algorithms are used for optimization but here we are using them to explore creation. Again our GA (genetic algorithm) is inspired by darwinian evolution so we will be acting
as nature by selecting individual compositions as though they were essentially animals and allowing them to reproduce and spread their genes to the next generation. As we do this we will be creating more favorable and interesting compositions.
Each composition consists of eight triangles and one octogon to create an image. Each shape in the composition contains six main genes that are used in mutation, selection, and crossover, the biological operators that allow us to simulate the darwinian evolutionary process.
Each composition also contains a gene to determine the underlying color scheme that all the shapes color in that composition must be comfined to.
Genes in our GA, and in most GA implimentations, are represented by a value between zero and one inclusive. This gene structure can be visualized in the diagram below.
How the shapes are generated
The polygons are created by starting with the center of the polygon, x and y, and sampling points on a circle around that x and y center with a given radius.
Random noise is added by varying the angular spacing between sequential points and by varying the radial distance of each point from the center.
Then lines are drawn between the points chosen to draw the shape. The annimation below shows how polygons with varying number of sides can be
generated by sampling points from a circle around an given center. Note: the example below does not encoperate the varying angular space between the points and the varying radial distance of each point from the center.
Mutation, Crossover, and Selection
Selection is calculated for each composition and based on the selection, each composition is added to the mating pool a certain number of times.
For each composition, the higher the fitness the more entries are added to the matting pool for that composition and the more likely that composition will be selected as a parent to create a new child composition.
The crossover function then takes two parents and creates a child by taking the parents shapes and cloning them to the child.
The mutation function then loops through each gene in each shape in the composition and resets the gene to a random value between 0 and 1 if the gene is less than the mutation rate.
Otherwise, the gene is left alone. These three functions account for the innerworkings of the genetic algorithm in order to simulate darwanistic evolution.
Original inspiration and baseline for our genetic algorithms
Original implimentation that acted as a backbone for out genetic algorithm
Genetic algorithm selection, mutation, and crossover image
Thank you to Jenn Karson for overseeing the project and a big thank you to Lapo Frati for assisting me with p5.js and the genetic algorithm in general.