This is one of those things that have bugged me to no end.
The only thing that Darwinbots can't do smoothly in the DNA (well, there are some others too, but this is a big one) is nested conditions. Things like:
if nrg > 4000
if age > 2000
'do stuff for age > 2000 and nrg > 4000
else
'do stuff for age <= 2000 and nrg > 4000
end if
There are ways around this, but they tend to be messy and ineligant.
Anyway, this is how I'm thinking to modify the DNA flow control structure to allow nested conditions.
When the program comes across the first cond statement, it checks if it's true or false. If it's false, it finds the next stop statement that doesn't have a corresponding cond.
That's probably confusing. It's like this (cond in this represents an entire condition like we're used to):
cond <-evaluates to false, read until 1 stop is found
cond <- will not be evaluated, read until 2 stops are found
stop <- one stop found, read until 1 stops are found...
cond
stop
cond
stop
stop <- stop found, start normal execution again.
If cond evaluates to true:
cond <-- evaluates to true
cond <--evaluates to false
some code in the middle <-- isn't executed
stop
cond <-- evaluates to true
some junk DNA that isn't executed
start
program code that's executed
stop
cond <--evaluates to false
start
<--some code that isn't executed
else
code that's executed
stop
stop
I think that demonstrates all of it. (<-- are comments if you didn't catch that...)
so basically stop now hooks up with cond instead of with start and else, and cond interrupts the flow of start and else.
not terribly difficult to do.
Allows nested conditions without breaking existing bots.