Tuesday, April 13, 2010
Russian Dolls - Random combinations
Click on the image on the left to load the canvas demo (requires FireFox or non-IE browser)
This demo shows how a huge amount of content can be generated by randomly combining variations. This technique is useful as for example a crowd of identical people looks unnatural, but you don't necessarily care what the individuals look like, so long as they match a general theme.
The numbers get large very quickly - for instance 3 variations of hair color, and 2 of eye color gives 3 * 2 = 6 possible combinations (assuming independent assortment). Adding another trait multiplies this again, and soon the number of possible variations becomes enormous.
The code internals do not resemble genetics, but there is a similar idea in nature, with alleles. In the future I may use the dolls and their many variations as phenotypes for some experiments in this area.
The reason I chose to use Russian dolls (aside from just liking their recursive nature) is because my daughter Caitlin has lots of them on various clothes, bags, sheets etc, so this is for her.
It works fine in FireFox but there is something strange going on with parts of the faces not being drawn in some versions of Chrome.