A Perfectly Stupid Robot
Okay so what do I mean this is a stupid robot? Glad you asked, here we go!
Imagine a traditional robot program, maybe something like:
If Light Sensor Left Turn Left
if Light Sensor Right Turn Right
The instructions are pretty specific, and require the bot to know a lot about itself: How to operate the its motors to drive, how to read a light sensor, etc. It has to know what's connected to it, and how to use it correctly.
In contrast, Zero doesn't know nothin'. It has no idea what's attached to it, or how to operate those things. And it doesn't have any specific instructions at all. That sounds bizarre but this will start to make sense soon.
Here's is what one of its programs might look like as pseudocode:
Read from In Pin to In Register
Do nothing next, if Out Register greater than In Register
Increment Out Register by your age in ms
Add the value of In Register to Out Register
Write the value of Out Register to Out Pin
What could such formless nonsense even do? Well, that depends.
First clumsy steps of a young GA: Early Generations in "Box3"
Vegas is Easy
If the instructions ran when "In Pin" happened to be connected to a light sensor and "Out Register" (by sheer luck) held the previous value of the sensor...and the sum of the robot's age and sensor reading were a value appropriate for sending to a servo...and (again by luck) a servo was attached to "Out Pin"...
Then that servo would move in response to some sort of light stimulus.
That is a lot of sheer luck! Flipping 8 coins and getting all heads kind of luck. You'd have to flip them like, a billion times, right?
Let's do the math: The number of possibilities with one coin is 2^1 = 2 (heads and tails, one coin). So with 8 coins there are 2^8 = 256 possibilities - only one of which is all heads.
So if you flip 8 coins 256 times, you're almost certain to get all heads at least once. If not, then at least by your 512th flip. Unless something is very wrong with your coins, or your universe.
256 coin flips will take you a long time, but these days a $2 microprocessor on two on AA's can do about 16 million per second.
Getting lucky is pretty easy when you flip coins that fast.
50 generations later, IQ Zero sports some mad dribbling skills
Engineering with Chaos
But that can't work - throwing a bunch of dice in the air and simply hoping they fall in just the right way to make something useful?
You are absolutely correct: The first throw of the dice will probably produce nothing useful.
But Evolution isn't just random - its other engine is natural selection.
Once the GA has lived its life (its "fitness test"), it is scored on how well it performed. In the prototype, that is how many times it triggered a motion detector (its "fitness function").
Only the combination of random dice which performed best is chosen as the winner. Several copies of the winner are made, but each slightly changed by a random mutation in its DNA.
Repeat this process over and over and (tada) - Evolution on the ATTiny85.
What did I mean by "this is what its program might look like?" Don't I know?
No, I don't - I've never seen one of its programs. It would be almost impossible to interpret anyways.
Zero's "DNA" - most of which becomes its program - is a very long list of "random" data.
I've put random in scare quotes for those who know no such thing exists - certainly not in digital computers. No matter how you work it, everything digital is completely deterministic.
To generate a random value, most platforms require some sort of "seed" value for their PRNG (Pseudo Random Number Generator). The PRNG uses this seed and some weird formula to generate a long list of numbers that you would have have difficulty predicting.
But given the same seed, that formula will generate the same list of "random" numbers, in the same order, every time. Of course that's not random.
This can be real problem for applications that need random data, but for Procedural Generation techniques it...Read more »