Building a Genome

After taking my color progression script as far as I thought it could go with a random progression, it was time find a more sophisticated approach. In the original script the color would change from one block to the next by randomly selecting the red, green or blue value and then changing it by a random amount. This meant that while the color meanders randomly, it maintains a similarity to the blocks next to them because two of their three RGB values will always match. In the non-random progression I’ve started, I’m instead changing the three color values at the same time, but at different rates. This means that while the red value will change with a constant pattern, the overlapping of all three patterns should obfuscate the patterns, as long as the three patterns do not have similar periods.

The change in each color value has five parameters. The first parameter is binary, yes or no, is the color currently changing? 0 means no and 1 means yes. The second parameter is the initial value of the color, this ranges from 0 to 255. The third parameter is the amount that will be added to the color value when it changes. The fourth value is the number of consecutive times the color will change, while the fifth value is the number of consecutive times the color will not change. Since all three colors have these five parameters, each color progression can be described by a series of 15 numbers. Given 1 digit for the first parameter, 3 for the second and 2 each for the third, fourth and fifth parameters, you are left with a 30 digit number. This number holds all the information needed to build any one of the color progressions the system is capable of, in essence it is a genome.

I’ve generated a series of progressions given random genomes. Some of them are interesting, and others, not so much. I need to find a way to determine which codes produce the best results. The reason I went through the trouble of designing the progressions around a genome is so that I could use a genetic algorithm to find the most interesting patterns. I’ve never written a genetic algorithm script before and it’s something I’ve been wanting to try. The real challenge in doing this is establishing a fitness test. How do I teach the computer to differentiate between an interesting progression and an ugly one? My plan for now is not to try, since it’s practically impossible to teach a computer to evaluate aesthetics. Instead I want to set up a ‘Human in the Loop’ algorithm that presents a user with a series of progressions and asks them to select the ones they find most interesting, using this as a fitness test to drive the genetic algorithm. It would really be nice if I could it get set up online so anyone could try it out.