To all the code monkeys out there, hello! This is my first post on this forum.
I've always enjoyed search algorithms, and simulations, so I thought, why not combine the two (Specifically, a genetic algorithm). I'll explain my idea below, let me know what you think.
1) Take any picture. For this example, I'll use one we are all familiar with, the Mona Lisa.
2) Using "Powder Toy" and a genetic algorithm, start placing various arbitrary components on the screen, and let them run through the simulation 1000 frames, or whatever, and take a screen shot of the result.
3) Do that for every random member of the initial population.
4) After each simulation has run, calculate the "fitness" of the screenshot. This is determined by how many pixels are the same color as the original Mona Lisa (or image of your choosing).
5) Anyone familiar with GA's will know what we do next. If not, go find a YouTube video on GAs and you'll be an expert in no time. It's really not terribly complex.
Is this possible in TPT? I'm only just starting to look at it, but from what I've seen, I should be able to write the code in LUA as plugin perhaps?
Am I crazy to think I could do this here?
Any input is welcome, and let me know if you need any clarification.
Thanks!
That's to be expected. Genetic algorithms are notoriously slow, but they are also incredibly fun to watch evolve over time. It would be cool to run it as a screen saver too.
Or, to speed things up, the equivalent of a server farm could be developed I believe. If speed is the issue, would it be possible to run the engone, and subdue the display while it runs? That might speed up rendering, not sure.
Does anyone have any idea on how to represent the chromosomes?
As I mentioned above, I envision the simulation running for 1000 frames, or more, or less, whatever makes sense when the time comes. In fact, it will probably be customizable.
During the course of those 1000 frames, I envision new materials being added. For example, a "photon" material is added on frame 57, and imagine dragging the mouse from x1,y1 to x2,y2, and have some arbitrary color. So, in that case, the chromosome would need to know:
1) particle type
2) frame begin
3) x1, y1
4) x2, y2
5) color
I'm proposing the following object definitions:
1) Material - 8 bits - referring to 1 of 256 possible materials (too much?)
2) Frame begin - Instead of trying to have a bit for each individual frame, I think I'll divide the toal frames by 15, and start on that frame. So, if the total frame count is 2000, a material could be introduced every (2000/15 = 133) 133 frames. Thus 4 bits. Let me know if this needs further clarification.
3) Can one of you TPT veterans give me advice here? Are the X and Y axis' customizable, or fixed? If fixed, what are those dimensions? We will need enough bits to store the x and y max values.
4) Same as 3.
5) Color. I may dumb down the number of colors available to limit bit use. Let's say 4 bits for now, allowing 16 colors.
Thus, a single chromosome will look like:
XXXXXXXX XXXX XXXXXX XXXXXX XXXXXX XXXXXX XXXX
And the simulation will consist of multiple populations of chromosomes, each population evolving independently. Does that make sense?
Any thoughts on this would be appreciated.
Also, as I'm just starting, does anyone have any ideas on calculating the fitness? Ideally, I would need to compare the final result of the sim, to the desired picture, and say the result is some percentage of closeness to the original image.
Thanks!