Drawing generator algorithm
Reproduce enough children to repopulate the next generation.
![drawing generator algorithm drawing generator algorithm](https://i.imgur.com/Zv2kYmv.gif)
Using tournament selection or stochastic acceptance determine which remaining DNAs should reproduce to make the next generation of DNAs.Optionally, kill off the bottom x% (lowest fitness) of the population.Optionally, allowing elitism, select the most fit to succeed to the next generation.Measure the fitness of all of the DNAs and sort them by fitness.Randomly generate a population of DNAs.Population-Based Two Parent Genetic Programming ( PopulationBasedGeneticDraw.kt) If the child's DNA is more fit than it's parent's DNA, then set the parent to be the child.This is done by drawing the polygons to an image and comparing it pixel-by-pixel to a target image. Make a clone of the parent DNA, randomly mutating some of it's genes.Single Parent Genetic Programming ( SingleParentGeneticDraw.kt) This is more accurately defined as the error function and works just as well. In this program, 0 is perfect, meaning the evolved image is exactly the same as the target image. The difference between the target image and the actual image is defined as the fitness of the DNA. The rendered image is then compared to a target image.
![drawing generator algorithm drawing generator algorithm](https://www.101computing.net/wp/wp-content/uploads/sudoku-grid.png)
When a specific DNA is "expressed" I iterate over each of the genes and render the encoded polygons to an image. In addition each gene encodes the color, location (including z-index), transparency, and size of each polygon. The polygon could be a square, circle, rectangle, ellipse, triangle, or N-vertex polygon. The DNA is a list of genes where each gene encodes a polygon. Both algorithms demonstrate the use of Genetic Programing to evolve an image from DNA(s). There are two algorithms used in Genetic Draw.
#DRAWING GENERATOR ALGORITHM CODE#
The code can all be found on GitHub: here The Algorithms