# Evolving Mona Lisa

Using the so called Continuous Gray Code optimization algorithm to evolve an image of Mona Lisa with circles.
https://www.cs.bham.ac.uk/~jer/papers/ctsgray.pdf
The wide variation of mutation strengths allows it jump out of local minimums better than most simple evolution algorithms.

https://editor.p5js.org/siobhan.491/full/1qRYZ5r0i

I don’t know what the edit link allows, I presume you get a copy of the code!
https://editor.p5js.org/siobhan.491/sketches/1qRYZ5r0i

2 Likes

Thank you for sharing this!

Are you getting good results? What kind of runtime does it take before something like a figure emerges?

You are viewing / running the original, but editing it locally in the browser. If you want to save / duplicate, it becomes a new sketch – people cannot edit your copy without your username and password.

For example, I selected “Duplicate” and added a counter:
https://editor.p5js.org/jeremydouglass/sketches/tfIaIPXLJ

Okay, got it. It should only take a few minutes to see something happening.

Odd. The target domain seems to have different dimensions than the source domain.

It runs fine on the Palemoon browser. Perhaps it is that high resolution display mode thing again (the 4 pixels per pixel thing!!!) I had some issues around that with my connect 4 game. Or other people had issues I should say.
I certainly don’t have hi-res anything. I have the remnants of a laptop that I have to start with a screwdriver.

Yes you see in the costL2 function there is pixel level access:

``````function costL2() {
var cost = 0;
for (var i = 0; i < ml.pixels.length; i += 4) {
var d = ml.pixels[i] - eg.pixels[i];
cost += d * d;
d = ml.pixels[i + 1] - eg.pixels[i + 1];
cost += d * d;
d = ml.pixels[i + 2] - eg.pixels[i + 2];
cost += d * d;
}
return cost;
}

``````

That is why in the isometric game I avoided anything to do with pixel access.
I haven’t done much code with JS/P5 and it will take some time until I can get some proficiency. However I really like the online editor and ability to share.

1 Like