evo_camo_game
May 28, 2021
Based on: TexSyn version 0.9.7 (alpha macOS-x86_64)
For any problems or questions, contact Craig Reynolds: cwr@red3d.com
This is an alpha test version of software for “interactive
evolution of camouflage” as described in my 2011 paper: Interactive Evolution of
Camouflage. This 2021 app evo_camo_game
is built from new components: the TexSyn library
for procedural texture synthesis, and the LazyPredator
library for evolutionary optimization via genetic programming.
For more information see the development blog
for TexSyn.
This program is a crude simulation of the evolution of camouflage in nature. There is a predator-prey system. Software for texture optimization plays the part of an evolving population of camouflaged “prey.” The human user serves as a predator hunting its prey with vision. This can be seen as a sort of minimalist “game” or a human based computation. The app displays a window with a random portion taken from a given set of photographs. Over that background are drawn three randomly positions disks of synthetic texture—three “prey.” The human user/player/predator then decides which of the three textures/prey is most conspicuous or least well camouflaged, indicating their selection by clicking/tapping on that prey. The window will go blank then display the next step. Runs typically consist of 1000 such steps or more. They can be stopped at any time. Results are currently saved during as image files, and texture “source code” in text files, as described below.
Download evo_camo_game_0_9_7.zip
from this Google drive page. Click the
download button in the upper right. It should download and
unzip, putting the evo_camo_game
executable file
in your Downloads folder. (Its icon says “exec.”)
Open a new Finder window, use ⇧⌘G (shift-cmd-G) then type in /usr/local/bin
[return]
Drag evo_camo_game
from Downloads to /usr/local/bin
Open a Terminal window, like an old fashioned unix/linux shell.
Type evo_camo_game
[return]
It may pop up a window like this:
If so:
evo_camo_game
[return] againAt this point, if you are lucky, it should print ~14 lines and exit:
> evo_camo_game All unit tests PASS. Run time for unit test suite: 0.0482377 seconds March 16, 2021 evo_camo_game requires at least one pathname parameter, others may be omitted from the end: background_image_directory (required) output_directory (defaults to .) background_scale (defaults to 0.5) random_seed (else: default seed) window width (defaults to 1200) window height (defaults to 800) individuals (defaults to 120) subpopulations (defaults to 6) max_init_tree_size (defaults to 100) min_crossover_tree_size (default max_init_tree_size_ * 0.5) max_crossover_tree_size (default max_init_tree_size_ * 1.5) >
If you get that far, all is well.
To use the app you will need a collection of background images.
That “oak leaf litter” set (see https://cwreynolds.github.io/TexSyn/#20210209)
is six photos taken with my phone's camera. Later I will add
more more about how to curate these background image sets. The
photos in a set should be visually similar. They will work best
if they contain a “granular” structure, say a collection of many
leaves, or pebbles, or flowers, or beads... See samples of this
in my 2011 paper or these
presentation slides. I think it works best when the camera
is pointed directly at a mostly flat surface (so no perspective)
and all photos in the set should be from about the same distance
(so same texture scale).
You can arrange files however you want, but lets say under /Users/YourName you make a new folder “camouflage” with two sub folders “backgrounds” and “runs”. Let's say you shot a handful of photos of a bed of clover. So the folders might look like:
/User/ YourName/ camouflage/ backgrounds/ clover/ IMG_9821.jpeg IMG_9825.jpeg IMG_9826.jpeg runs/
(Note: in case you want to try running evo_camo_game
but do not a suitable background image on hand, the sample
clover image shown below is available for unrestricted use by
anyone. I have posted it here.)
To run the app you would type in Terminal at least:
> evo_camo_game ~/camouflage/backgrounds/clover
(Note: you can literally drag things from the Finder into the Terminal window. So you could type “evo_” [tab to complete], drag the “clover” folder from a Finder window into Terminal, and you will have the result above.)
To keep track of your output files, better to specify the place to put run results. Each run will create a time-stamped folder under “runs”:
> evo_camo_game ~/camouflage/backgrounds/clover ~/camouflage/runs
This should pop up a window, its title will be “clover (step 0)” (see below). You will see some portion of one of your clover photos, with a “tournament” of three competing textures. Remember they are completely random at this point, so will look nothing like the background. Do your best to pick the one least like the background and click on it. (In the example below, I might go for the one in the upper right, but it is up to you, whatever seems least like background.) The window will clear, then redraw. Then just repeat that process hundreds to thousands of times. Try 200-300 and see if you notice the textures looking more like the background. When I do a “full” run, it is about 2000 to 3000 steps.
The app supports a few GUI actions:
mouse (left) click | End a step by clicking on one of the prey
to indicate: “eat this prey” / “this one is least-well
camouflaged” / “most conspicuous” (Clicking anywhere ends the step, if you do not click on a prey, it is as if a random choice is made.) |
shift mouse (left) click | Save thumbnail image file for indicated prey texture. This is a .png image file with the prey centered, surrounded by a bit of its background neighborhood. It also writes out a .txt file that contains the source code than can be used to re-render the texture at arbitrary resolution. |
t key |
Save tournament image file. A .png file
showing the entire window, with three prey textures
drawn over the background. |
Q key |
Exit. (You can always exit from the Terminal window command line with ^C (control-C) or ⌘. (cmd-period).) |
These image files are saved into the output directory given as
the second argument on the command line. evo_camo_game
creates a sub directory for the run with a name like: clover_20210228_1834
(that is: RunName_yyyymmdd_hhmm). If you start a run then don't
want to save anything, feel free to delete the run directory.
Eventually other run records, like logging and check-pointing
populations, will be stored in this directory. A saved
“tournament” image is similar to the clover image above, minus
the title bar of the window. Here we see tournaments from steps
102, 1000, and 1982:
A saved “thumbnail” image looks like this, the disk-shaped prey with camouflage texture in the center, and a bit of the background behind it:
The command allows you to set a lot of parameters on the command line, which you can ignore at first, but fyi they are listed if you run the command with no augments:
> evo_camo_game evo_camo_game requires at least one pathname parameter, others may be omitted from the end: background_image_directory (required) output_directory (defaults to .) background_scale (defaults to 0.5) random_seed (else: default seed) window width (defaults to 1200) window height (defaults to 800) individuals (defaults to 120) subpopulations (defaults to 6) max_init_tree_size (defaults to 100) min_crossover_tree_size (default max_init_tree_size_ * 0.5) max_crossover_tree_size (default max_init_tree_size_ * 1.5)
So for example:
> evo_camo_game ~/camouflage/backgrounds/clover ~/camouflage/runs 0.3 20210310 1600 1000 200 10 150 100 200
The background scale allows you to adjust the size of the photos relative to the window.
If you do two runs, you may notice some of the same textures coming back in the second run. You can use “random seed” to avoid this. I've been just using the date (as in 2021-03-10 → 20210310) to make sure today's run is different from yesterday's. Any number will do.
Lots, but a key one is a version to run on the M1 processor. If
you need a version for Windows or Linux, let me know and I will
look into it.