Let's Make Robots!

Darwin is a hacker

How many monkeys on type writers does it take to write the collected works of Shakespeare? Or Asimov for that matter? It has been claimed, but never tested, that a limited amount of monkeys will indeed produce such a work.

Given enough time...

I think I can emulate a finite amount of monkeys hitting random keys. I just did so. It's a perl program of about 300 lines that produces Picaxe Basic. Or rather, it produces absolute nonsense, and then feeds it to the picaxe compiler for a quick syntax check.

Every bit of gibberish that makes it through the test is relabelled as "viable" picaxe code. It is stored somewhere safe for future retrieval. And this is where my monkeys get a bit smarter. They copy pieces of existing picaxe code. The better the code, the more likely they are to reuse it. And add to it. Or delete parts from it. Or paste it into their own. But most of all, they will combine it with other pieces of existing code. And thus produce new code to be tested by the compiler.

Now, admittedly, I am a cheater. I gave my army of idiot programmers a few snippets of code. The very minimum lines like "b0=0" and "pause 1". And it shows. These snippets are reappearing all over the place. In about an hour, my collection of viable programs has grown from 5 to 500. One combination for example now reads "pause b0".

This is not enough to me. I want a real picaxe to start using this code. And I want some way of telling the monkeys which pieces did something really cool while uploaded to the micro controller. I am still without such a feedback system. It could be all kinds of stuff, but most of all, it needs to be dead simple. The feedback system is taking shape.

And it need to be something visible, so I can broadcast the experiments on live internet TV.

So, my monkeys.... What kind of ideas will you copy and paste together for this cool experiment?



# 201005121529 rik (1069) letsmakerobots.com
# artificial evolution of micro controller code
#  Picaxe Basic in my case
#  Warning: this code is highly experimental - might just be mental

# 201005121611 let's introduce point mutations
# 201005121611 let's introduce rudimentary evaluation functions
# 201005121809 let's introduce sort by_fitness into select_creature
# 201005121950 let's introduce specific picaxe basic genome cleaners
# 201005131258 let's cleanup not-dead code upon loading
# 201005131818 let's cleanup code before determining id (plus other major improvements in quality)
# 201005131819 let's prevent two identical pieces of code to exist in the db
# 201005132025 let's try and rate the quality of a compilation
# 201005141604 let's remove some non lethal bugs
# 201005141607 let's reuse make_creature in the main loop
# 201005141621 let's cleanup accolades (curly braces) and reduce labels to one alpha char
# 201005141717 let's not shorten labels, it destroys potentially interesting dna
# 201005141723 let's dump all genomes in one huge logfile for online monitoring
# 201005141738 let's expand the fitness range for dead genome: 1-9 depending on location of syntax error in the code
# 201005141756 let's give small viable programs a small advantage when memused is just over 4 bytes
# 201005141856 let's compile code with newlines replaced by spaces so that we know the exact length of the code
# 201005141948 let's no longer compile code with newlines replaced by spaces, it's another bad idea, the code appears to be functionally different in some cases
# 201005142036 let's cleanup backslash-doublequote combo's
# 201006011238 let's allow for father and mother to be the same creature (!)
# 201006011441 let's rename "retired" into "buried"
# 201006011824 let's stop replacing empty genome by an arbitrary string (a:) and start evaluating it as fitness = 1
# 201006011929 let's move all the sorting and counting of %creature to the top of the script, saving tons of CPU cycles
# 201006022235 let's cleanup trailing newlines
# 201006032139 let's push any new ids to the array @ids, without bothering with expensive sorts
# 201006032154 let's no longer worry about genomes shorter than 2 chars, they too have a purpose in the gene pool

Continue reading here.

3evolve.pl_.txt12.35 KB
4evolve.pl_.txt13.31 KB
5evolve.pl_.txt14.66 KB
6evolve.pl_.txt17.05 KB
7evolve.pl_.txt17.23 KB
8evolve.pl_.txt19.5 KB
1population_management.pl_.txt5.67 KB

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

Stranger even than that!

Random code can lead to new knowledge. Did you know that this:
compiles just fine?

But what is worse, near such a backslash-doublequote monstrosity, the compiler will accept all kinds of gibberish!
Compiles just fine!

Don't they understand that this is a gateway to evolutionary hell?!

I just did a quick "back of an envelope" calculation. And it turns out that the odds of finding a word (any word) that exists in the picaxe manuals through combining random characters are ASTRONOMICAL.

That will not do!

So I did some major cheating and injected the entire index of manual 2, containing some 1500 discrete words. Now it turns out my algorithm does not respect that either. It is chomping on infinite variations of the word "disconnect".


I get the hint. I'm off to bed.

Rik, are you familiar at all with the halting theorem?

I get the feeling that if not, you're going to encounter it pretty soon. Have fun with that.

The other thing is that I can see a flaw in your test: that is, the code you produce (if executed on a picaxe) could actually result in a large number of different outcomes, depending on how the chip is wired up and what to. The same program could potentially perform many different tasks, all dependent on the hardware the chip is plugged into.

Also, I'm not sure how many keywords there are in picaxe code, but even if you were to start with a language of only valid keywords, there are billions of possible combinations, and only a very few of them will actually do anything interesting.

I never intended my experimental robot to run the program until the program decided for itself to halt. I planned on giving it like 60 seconds of running time before I (automatically) upload the next code for testing.

This is the beauty about my kind of experimenting. It's just for fun and glory (thanks TinHead).

However, the problem of the astronomical odds is very real. I have yet to find a way to circumvent it. I already learned that the evolution algorithm needs to be able to recognize even the smallest advances in fitness. And I am not sure how I will implement that once I am ready (if ever) to start uploading genomes into my arbitrary robot.

My population manager is killing creature by the millions, but the project won't die. The physical habitat for the viable creatures is underway! Stay tuned.

[image intentionally obscured - dum dum dummmm!!]