ca-ga running


It's just a toy. Evolving cellular automata with a behavioural DNA 1k instructions long (4k instructions in the neural versions) and a mutating fitness function. Which is to say the fitness function itself mutates depending on the contents of cells at twelve hotspots, an idea I got from Jeffrey Ventrella's Earth Day CA.

Feel free to go in and tamper the variables. Most of the important ones are constants, like the dimensions and size of the DNA. (Neural version wouldn't be hurt by going up to 32k or more.) There actually are no settings or arguments. You can save the whole population with PgDown. Copy the ca-ga.whole-pop.dna and .brain file to ca-ga.whole-pop.load.dna and .brain for loading later with PgUp. Or, you can hit 'x' to just export a few strains. Copy one to ca-ga.load.dna to load (hit 'l'). OK... Hit 'h' in the window to print help on stdout.

PgDwn saves your whole population to ca-ga.whole-pop.dna and (in the neural version). ca-ga.whole-pop.brain. Move these to ca-ga.whole-pop.load.dna and (in neural version) ca-ga.whole-pop.load.brain respectively, then hit PgUp to bring them in. Hitting PgUp without the *.load.* files in place will probably result in a crash. I can't remember. Good luck! flamoot

OK I got the new ones ported to Windows. I've been working on the "stim" version a lot lately, that's the one you should try first. It has multiple views and sound channels and some controls for moving around em, I just broke savefile compatibility in stim though to get four-byte generation counts. Ahh. It's real good. Evolves a grid to sound like a target wav (just replace brone.wav with something if you want) and has self-modification and drugs. Try it out. Cheers flamoot

(I don't know if brone.wav's over 10 seconds will work. I'm using one now by not playing it at the start, which I think is where it'll break. Of course Windows users don't have this option unless they recompile it themselves with MinGW. Playing the target wav first lets you make sure it's the right speed etc. So I have to leave that in. Just use short recordings if you have to but if you find out you can use a long one without sound playback breaking let me know ok. I should just try it myself maybe I will oh god)

sources (for linux, require sdl) (rev 4.99.99, synapse addresses in genes now modulo'd by living brain size not max brain size, more dynamic. i didn't update the version number after this change because 4.99.99 is really the last one. there will be no more silent updates so you can feel pretty safe using this version until 5.0 is ready. before: saveall/loadall added (untested in linux!), changes to remove neuron/synapse reverted. last version before 5.0 ... rev 5 will have a tiled multi-view display, crash-proof resizing and switchable fights. self-modification, spatial brains w/ neurotransmitter hydrodynamics, switchable child rebooting and networking are slated for 5.5)
ca-ga.c -- pure genes (neuronless) version, the app you [probably] want. strangely beautiful. DNA was reduced to 2KB so they actually run it all in non evolutionary time. (Since rebalancing this version they only seem to execute 512 bytes even after 2500 generations so, to avoid gigabytes of wasted copies, I've reduced the DNA in this version to a paltry 512 bytes. That's only 256 instructions, ever, but it's faster and less wasteful than copying long DNA's they never use 3/4 of. You can always change DNA_Length yourself. Use multiples of 2 [4 in neural version]) brainfile build error removed >:/ i think this would make the crazy art i saw in revision 2 if i removed the fight opcode so i will probably add a switch for it in 5.0
ca-ga-fightless.c -- in fact here's a version of the above with fights hacked out. probably they're not a good idea anyway in the non-neural/pure-genes version. blank Fights View is the only wart. high hopes for this one (it may produce the wacky, organized biological art i blame revision 2 for later [revision 2 didn't have Fight that's why I did this, arg]... ok i've evolved with this for a while now and it makes too many stripes. I think the pure-genes fight version, ca-ga.c above, comes closest to making the art I saw before. (Note no, it's too cold, stays mostly blue, you can search "fade" and set it even higher than .99 if you want, just not higher than 1, anyway, I just set the Linux versions of these first two sims to be warmer, fade of .99, so this fightless version should make decent art now and hopefully not just stripes anymore but I still have to see. I also changed them both back to box dimensions instead of ropy ones))
ca-ga-fightless-box-no-wrap.c -- well i did like 10,000 generations in this one, where the edges don't wrap, and it is a box, and you don't really see the lines I was weirdly getting in the box shape ever since revision 2, right... and I got really good animals that like, breed and poke, they might have multicellularism. And I guess I don't see those lines anymore. So check this one out and I'll port it to Windows when I can.
ca-ga-ann.c -- neural version, experimental, but probably i'll move the whole thing to this for rev 5 if it works out... DNA instructions are twice the length in the neural version, so the genomes are 16k (DNA isn't rebooted in the ANN versions so any length will eventually get executed)
ca-ga-ann-brainfuck.c -- secondary fitness function (reference Avida's 'resources' where stepped energy rewards were available for implementing logic ops) proof of concept, replacement for sound version, has neurons and brainfuck. evolves cellular brains to look at a brainfuck program and predict its memory/state after 1k cycles. writes ca-ga.log itself as a bonus
ca-ga-ann-brainfuck-brainview.c -- ok i modified that one to be only like 50x50 which is faster with three times the mutation rate to compensate and, you can see the neuron potentials in the top cell's brain instead of the dna's, in this. it's compatible with ca-ga-ann-brainfuck populations its just a different size. linux only yet
ca-ga-ann-bf-bv-wave.tgz -- ok here's a version of the brainview one that can read a wav file and make sound, just change the filename at the top of the program. you need the two small wavs in the tgz to be in the current directory, ok. then it should evolve to sound like the wav you specify. Add -lSDL_mixer to compile
stim.tgz -- [someone had my password and rolled this version back a bit. it doesn't have the multi view of every view and you can't use all the views as sound sources in it, anymore. Use stim for windows instead, it's got the features this one doesn't anymore, and I can correct the Linux version when I get back home to be as good as it by mid-July I hope. Aaargh!] use this instead you can change sound sources with 'j' its, the above with drugs added bye


windows (sources and binaries, for ninjas and wimps)
stim-mingw.rar -- [This link was dead for a while, someone had my password. There were other bugs like added or something and it seems to crash after a while. I'm hunting down the crash, but it runs long enough usually to converge on target.wav which is not brone.wav in this, it's just this alarm sound from the Kismet wireless sniffer. It converges super fast like in a few minutes but then crashes still and I'm trying to find out why. God damn...] ok I think this is the best neural version. It tries to create a sound wave like a target by training the potential on a neuron that votes for samples of audio. It's got self-modification and contagious drugs. It shows their brains, not their DNA, (Y toggles synapse view) and makes a sound wave. You can change brone.wav to something else if you want. Hit 'J' to toggle sound types, I'll have it so you can do any view as sound later. Comma and Period adjust volume. It still has to learn to read brainfuck, lol
ca-ga-ann-bf-bv-wave-mingw.zip -- same as stim, above, just without drugs and self-modification in case you dont believe in those
ca-ga-ann-brainfuck-brainview-mingw.zip -- silent version of bf-bv-wave. no sound fitness function in this. it's also from before self-modification and drugs but it deserves to have them added. I'll put them in this but I've been busy with the stim one lately. It's the best
ca-ga-ann-brainfuck-mingw.zip -- should be the same as the last one but it shows DNA not brains. just the neural version with brainfuck added. needs drugs and self-mod put in too
ca-ga-ann-mingw.zip -- neural version no brainfuck. needs self-mod and drugs
ca-ga-fightless-box-no-wrap-mingw.zip -- OK so this is a non-neural version, purely genetic, it's way faster and makes fascinating patterns but is also way simpler. I disabled fights because the DNA's are dumber than the neural nets and I disabled wrapping at the edges so it's not a torus and I think this is the best pure-genes version so far. But I will make another no-wrap one with fights put back in, later.
ca-ga-fightless-box-mingw.zip -- Same as the above but back in a torus shape (edges of the grid can wrap)
ca-ga-fightless-mingw.zip -- Same as the above, toroidal and fightless, but wide and ropy, not a box, I think
ca-ga-mingw.zip -- Basic pure genes version, in rope dimensions, with fights, for Windows
ca-ga-box-mingw.zip -- Basic pure genes version as box with fights for Windows. How will you choose?! Take my advice, use stim ^-^
rev2-mingw.zip - revision 2 from Old Versions, buggy but made great art sort of, for windows. i think fightless-box-no-wrap is almost as good as this in terms of the art it makes in the energy view, now. but stim is the highest tech



what a mess
They're all worth trying on their merits but when I get a new place to cook, I'll get some version evolved out past the ten hour mark and condense the options to the best ones. Really sorry about that just pick one. Linux users actually have it easier here particularly since they can go in and hack it. Search for "fade" in the source to address the board's 'temperature', if you want to. I think fading in two places, like in Linux's revision 2, was better than in one place, like in Windows', but I can't figure out why yet

Note that using 'L' or 'PgUp' without a ca-ga.load.dna or ca-ga.whole-pop.load.dna file to load, respectively, still results in a crash. I'll get that in for 5.0 meanwhile just man up

tools
plot-ca-ga-log.sh -- graphs cell behaviour over evolutionary time using logged ca-ga output and gnuplot
graph-all.py -- calls plot-ca-ga-log repeatedly to display some useful charts
graph-all.py -- same for ann version
random-dna.py -- writes a random 8192-long ca-ga.load.dna, for loading into inbred populations
random-dna-ann.py -- same for ann version
sound-feeder.sh -- a script to read /dev/dsp for the sound version (predicts, not makes sound, though i have a pretty good idea how to use votes from neighbourhoods assigned positions in a quarter-second of 8khz audio to make sound, later, wow.)

only in 'old versions'
ca-ga-sound.c (no rev 4 yet, see 'old versions' below) -- reads /dev/dsp for a crude real world fitness function where cells have to predict another byte in the audio stream when given some as inputs...
ca-ga-tiny.c (no rev 4 yet) -- just much smaller dimensions and dna, more updates between draws... for experimenting with new opcodes etc

compiling
Go:

gcc -o ca-ga ca-ga.c -O3 -lSDL -g0
When making the sound versions, wave or stim, add -lSDL_mixer

You may also want to set -march but don't have to. The same command line works for all the Linux sources. Try -ffast-math, -funroll-loops, and the profiling options in gcc as well if you like

If you change the dimensions and get a segfault, it's just a failure of drawgrid. Change them again, very slightly

networked future
I want to let you assign an IP address to each edge, to stream populations across at some resolution for distributed evoution. If I work on this much more, I'll add it soon

something cool
You can change the grid into a diamond arrangement where the cold spots are at one side of each region, rather than at the corners of the board. This changes how DNA and brain designs propagate and might be better for smaller board evolution.

Find the following two lines in ca-ga.c or a sister program

        newcell -= 2*(abs((signed int)(i-y))/(y2));
        newcell -= 2*(abs((signed int)(j-z))/(z2));


And change the divide ("/") by y2 and z2 to a modulo, "%". This also appears in the comments but I thought I'd repeat it here. If it proves to rock, I'll switch

ramdisk for rev 2 sound thing
ca-ga-sound requires sound-feeder.sh to be writing to a ramdisk on /mnt/rd so google those if you don't know how to set one up and want to do that, ok

old versions
In case for some reason you want one of these

rev 1 - ca-ga.c.old ca-ga-sound.c.old
rev 2 - ca-ga.c.old.2 ca-ga-sound.c.old.2 ca-ga-tiny.c.old.2 these ones have bugs but look awesome and are crazy fast
rev 3 - unavailable
rev 4.2 - ca-ga.c.old.4.2 ca-ga-sound.c.old.4.2 ca-ga-tiny.c.old.4.2. i'd really try rev 2

You may have to change the filenames to have the extension .c for the compiler to accept them

extensions and commentary
In the new ANN versions, there are 80x80 cells, a population of 6400, and 16 kilobytes of DNA per cell, as well as 254 neurons available per cell and 16 synapses available per neuron. Which is remarkable because this makes 100MB of DNA and 100MB of neural net, 2 million neurons... the cells can communicate with their neighbours so they should be able to pool their neural resources to function as organisms with an arbitrary number of them. Each DNA is being evaluated one instruction per unit of sim time but rather than ordering actions on the grid like in the original version, it operates on the living neural nets with feedback from them. Copies and breeds of DNA are resumed at the father's instruction pointer and the state of its brain is cloned across, so brains are actually evolving even among genetically identical organisms who are clobbering each other without mutating. If you were to use 100MB of DNA as a single genome, evaluated in a serial fashion until it produced a neural net which was also 100MB, then test that neural net for suitability to some task, mutate the DNA (in any of a hundred million positions!) and repeat, I'm pretty sure it would take eternity. Here the DNA is granular and evolving modularly. It is varied throughout the ecology and hill-climbing in competition with itself in miniature. I have to evaluate all the neurons in parallel still but by comparison to the monolithic approach I described I only execute one DNA instruction per cell per epoch. Every time you run 6400 genetic operations, and evaluate the populations' neurons one time, you also fitness-test 6400 candidate components of the finished system. In this way, by breaking it into cells, I expect to be able to evolve this 200 megs of noise into one or more biologically inspired software controllers with an intelligence of n... in which case the CA will have come through at last. Thank the grid (and Conway)

brilanon@gmail.com 2011