Reading in the file requires parsing the outputted text back into something that the code can understand.
Essentially, our image is a series of rules, most of which are stored in a dictionary. However, in the database they are stored in a string, so to read them back in each column in my database needs a corresponding parsing function.
ParseCells is my attempt at this; a class written to contain function for the express purpose of parsing.
Now, it is time to see if what my functions have parsed will be accepted by a cells object, and if so, if I can manipulate them to recreate the image from these rules.
Creation of a Cell
Reading a cell in turned out to be more effort than just parsing and creating a new cell object. Once I had parsed everything through and created a new cell object, I ran into two problems.
- The newly created cell was not exactly the same
- Iterating was broken
Both these problems occurred because of how the code was previously written.
Debugging Recreating a Cell
Discovering faulty functionality in exporting
The first one it turned out was due partially to the way I was creating cellular automata. I turns out, a small section of code that I presume was supposed to be commented out wasn’t, which meant as the cellular automata progressed it randomized itself. This change was not recorded in the output, and caused the automata produced to share the same seeds, colors, and starting ruleset, becoming similar, but not the same.
However, removing the code where it randomizes itself makes it so that the cells can no longer iterate correctly.
This iteration is something that I have been fighting with for awhile now. I successfully wrote a function that appears to work for exporting, and automatically iterates as needs without randomization.
However, the iteration for reading in is very much broken. I know that reading in is happening correctly from the database, and that the drawing function works, however, somewhere between Cells and Pattern I am running into issues.
Odd functionality is being displayed where it *sometimes* works.
About every 1/10th times (but not predictably, it could be anywhere from 1/7 -> 1/15) the program will recreate the image perfect.
However, most of the time, it recreates something like this:
This ended up being because seeds was set before colors, when seeds depends on the size of colors to be set correctly. This was a very small detail, but explained how sometimes it would work (the data was then in memory), and sometimes it wouldn’t.
Mutate + Score + Insert into Database
Ironically, after making sure both image outputted and inputted were the same, I now need to make sure the new one is slightly different. This will be our mutation step in our genetic algorithm.
This step I ran into less trouble, and was able to successfully mutate the image using a premade function of mine, score it, and insert in back into the database.
Two cool things happen here:
- The image randomizes itself, including rules and colors
- The mutated image gets a change to become the “new best” image, and be mutated instead of the old one.
Unfortunately, the latter requires many clicks. This needs to be streamlined by having the program pick the top ~10 best images and mutate them.
Mutating Ten Different Images
This step is less than thrilling, as it involves reading in ten images and following the exact same steps above.
However, its introduction means that it is much easier to export mutant automata’s in bulk.
The results are in from the survey, and a brief overview of it shows a couple things:
The grey automatas that scored worse by machine were always rated better by participants.
These results seem discouraging and maybe all over the place, however, the ending questions were written for this scenario. In case our score was not validated by people, we wrote questions designed to ask the viewer:
- What color scheme do you prefer?
- What sort of shape breakup do you like seeing on a page?
The results of this were that people preferred similar color schemes, and that they did not like perfectly symmetrical shapes or the golden ratio.
Rather, participants preferred this breakup of shapes, what I dub the “complex 1/3rd rule of composition”
- Export does 10 mutations, is this number decent?
- Export changes 3 values in dead and alive, is this too much?
- Export only randomizes a portion of the colors, is this too little?
- Should iterations be mutated at all?
- Should the seeds be mutated at all? (not implemented)
- Findings of survey