Code center > Suggestions

Gene structure - cond start stop

(1/10) > >>

Zinc Avenger:
I've been thinking about the structure of genes.

The cond-start-stop structure is very fragile, practically any mutation in the wrong place will break it completely. It is also prohibitively difficult to evolve naturally - what's the chance a cond instruction will appear before a condition to evaluate, then a start will appear, then an appropriate action will evolve with a stop at the end? Vanishingly small.

So why not simplify it?

Remove cond and start.

Change the way genes are handled so that only stop is used.

Make the stop command define the end of a gene. So from the start of the genome to the first stop is the first gene. From the first stop to the second stop is the second gene. From the last stop to the end of the genome is the last gene. Make no stop at all mean the entire genome is one gene.

But that would not allow us to have conditional genes. So I got to thinking - if the gene is defined by the stop command at the end, why not make the condition the last part of the gene?

The way I envision this working is like this: Fire the gene speculatively, calculating the changes to the memory locations, but don't commit them to the simulation. If the value on top of the stack when stop is reached is greater than zero, commit the results to the sim. If not, discard them.

Numsgil:
That's pretty close to the way that the DNA works in the DNA module for Darwinbots 3.  Although instead of executing the gene speculatively and then checking the stack for values, the conditions are integrated into the gene.

The problem with using just the integer stack for conditions is when you try to introduce logic commands.  How do you represent true/false?  You could just do 0/1, but that doesn't really make sense.  What does 500 1000 > 30 add mean?  So you really need that second stack (the conditions stack) to keep the language clean.

For DB 3, a simple gene might look like this:

*.nrg 1000 > 50 .repro store

which entirely bypasses the cond-start-stop system.

As far as the current system, the gene structure is actually far more forgiving than people think.  Cond statements set a flag that determines whether start or else blocks are enabled.  A single cond can control lots of genes.  And if there isn't a cond statement anywhere up stream, the program just "assumes" a "true" value for the last cond evaluation.

EricL:
I think we want to keep the start codon as I think we want genomes to be capable of containing non-coding DNA.  We want a single point mutation such as the addition of a stop or the removal of a start to be able to have large impacts on the geneome, I.e. to be able to turn on or off whole genes, combine genes, split genes in two, etc.  We want junk DNA which can mutate for awhile without selection constraints and then get re-enabled.

That said, I like the idea of doing away with the cond and making it implicit.  I agree it would improve the probability of evolving conditional logic if such logic can be scatterred anywhere through the gene.  I don't think it would be too difficult to implement (he says in the confidence of ignorance) since the boolean stack is seperate from the integer stack.  There might be some sticky order of operations issues.  For example:

start
100 .foo store
*.foo 100 =
stop

Should the conditional logic use the old or the new value of .foo?

But I think we could work that out...

Numsgil:
You don't need to move the condition to the end of the gene if you use the condition stack, too.  You could have it anywhere in the gene you wanted to.

Laying aside the option of entirely deconstructing the idea of a gene as I've done with DB3 (which wouldn't be too difficult to do), you could have conditions interspersed within the gene.  Something like:

start
*.nrg 1000 >
10 .repro store
*.body 1000 >
stop

EricL:
I like that.  Saves a second pass through the DNA.  It's a running condition.  Memory operations happen when the top value on the boolean stack is true.  They don't happen when it isn't.  Thus a single gene can  contain multiple conditions and sub functions, only portions of which might get expressed depending upon the running condition logic.  Example:

start
*.eye5 0 >
5 .dn store
*.eye5 10 >
10 .dn store
*.eye5 20 >
15 .dn store
*.eye5 50 >
-1 .shoot store
0 .shoot >
0 .dn store
stop

Note that last couple of lines are a cascading condition.  -1 only gets stored into .shoot if *.eye5 is > 50 and 0 only gets stored into .dn if .shoot is less than 0 which only happens if *.eye5 > 50.  Cool.

Navigation

[0] Message Index

[#] Next page

Go to full version