Skip to content

Comment on Evolution of Mona Lisa in JavaScript & Canvasparent

Comments

bdOP

I don't do anything smart. These are just brute force mutations, always the same.

The only parameter tuning I did was to try several numbers of vertices per polygon for about 15 minutes and from there on I just used the one (6 vertices) that produced image I liked the most.

10 vertices produced too much noise, 4 vertices was kind of rough.

I started coding with possible variable number of vertices (that seems to be the case in the original algorithm), but it was just too slow in JavaScript.

Anyway, optimization can eventually collapse vertices, so basically I just hardcoded an upper bound.

And mutations are kind of soft, always just one element (R,G,B,A,X,Y).

I guess there is some place for improvement, for example by using HSV comparision for fitness. Though this may be slow. Raw canvas image data are RGBA.

Ah yes, I remember also that at the beginning it didn't want to converge at all when starting with random colors. It works when it can gradually build up from a blank slate.

for example by using HSV comparision for fitness

I tried with HSB. It didn't produce good results. The image was always too dark.

In HSB, colors that are far apart in our perception can have close distance. For example two colors with the same Brightness, Saturation but a different Hue.

Using HSB in the DNA was perfect. It's hard to mutate a RGB color in the right direction. You have to get 3 composants right. In HSB a single modification can change everything.

BTW, I coded a Java version after seeing the original. It works, but first, it doesn't converge very fast, second, it's stuck at: http://i33.tinypic.com/2yycdc8.jpg

On the bright side, I can easily switch the population size to 50. Java is very good at this. I piggy back on automatic hardware acceleration for rendering.

How did you get yours to converge sooo fast?!

bdOP

Mine is nothing, try the original program from Robert Alsing. He already released the source code and binaries:

http://rogeralsing.com/2008/12/11/genetic-programming-mona-l...

From what I have seen, he is doing extra type of mutations that I was too lazy to implement: move polygons in the stack (in addition to changing colors and moving points around).

Also how you do mutations matters: it seems smaller deltas are better, though they shouldn't be too small.

AboutSource Built by g1lg1l

Hackerly is an independent reader for Hacker News, built on the public HN API. Not affiliated with Y Combinator.