Thursday, March 5, 2009

cocoaevo

After seeing Mona and Lena and the inspiration behind that, Roger Alsing's blog post on genetic programming, I found myself writing my own slightly different version. Written in Cocoa it only uses two command verbs: brush and triangle. The generation algorithm simply pairs brush and triangle commands together whenever it places a new triangle. I also cheat by letting it sample from the source image. It still plays around with the color of the triangles after the initial color sampling.

Source:
CocoaEvo 106 KB
Disclaimer: hacked together in one night. The actual mutator code runs two worker threads, I ripped that code from another one of my projects, so the CodeMutator module is kind of a mess -- and that's really where the interesting stuff happens.

Some results:


Elapsed time for Dodo (illustration by Roland Savery) was ~19 minutes.



Elapsed time for Circle (illustration by Me;) was ~9 minutes.


Fun. Fun.