Darwinbots Forum

Code center => Suggestions => Topic started by: Gobo on December 03, 2007, 11:30:37 AM

Title: dupbool
Post by: Gobo on December 03, 2007, 11:30:37 AM
It would be extraordinary useful to have dupbool operator. For now, Sanger's nested if's do not work right, since only the deepest's if condition is checked. The right thing would be dupbool the top value and and it with a new condition.
Title: dupbool
Post by: EricL on December 03, 2007, 02:19:07 PM
dupbool would do what exactly?  Push another value onto the stack that is the same as the top value?
Title: dupbool
Post by: Gobo on December 03, 2007, 02:24:36 PM
Quote from: EricL
dupbool would do what exactly?  Push another value onto the stack that is the same as the top value?
Yes. And I havn't found a workaround to do it.
Title: dupbool
Post by: EricL on December 03, 2007, 02:28:42 PM
Me neither.  I'll add it in 2.43v.
Title: dupbool
Post by: Numsgil on December 03, 2007, 03:24:41 PM
While you're adding operators, a swap had been requested once upon a time.  And then go ahead and add a boolswap, too.
Title: dupbool
Post by: EricL on December 03, 2007, 06:00:39 PM
Quote from: Numsgil
While you're adding operators, a swap had been requested once upon a time.  And then go ahead and add a boolswap, too.
Swap swaps the top two entires in the stack, yes?
Title: dupbool
Post by: Numsgil on December 03, 2007, 07:35:11 PM
right.
Title: dupbool
Post by: EricL on December 04, 2007, 12:43:53 PM
dupbool
swapbool
dupint
swapint

added for 2.43v.  Names chosen by convention with other stack operators.
Title: dupbool
Post by: Gobo on December 05, 2007, 02:32:12 PM
Thanks. BTW,
Quote from: EricL
dupint
was known as dup. Is it considered alias now?
Title: dupbool
Post by: EricL on December 05, 2007, 02:52:36 PM
whoops.  Didn't realize it existed.  Yes, their aliases.  You can use either in bot DNA.  They have different underlying BP numbers in 2.43u, but I'll make them the same in 2.43v (so as not to skew mutation probabilities).
Title: dupbool
Post by: Gobo on December 05, 2007, 03:32:44 PM
It would be cool to have also over operators, which copy the second value on the top of the stack ( a b -- a b a ). For example:
Code: [Select]
if ( A ) {
    if ( B ) {
        C
    }
    else {
        D
    }
}
else {
    E
}
could be then coded as:
Code: [Select]
A dupbool B overbool overbool and C dropbool not and D dropbool not E dropbool
Title: dupbool
Post by: MacadamiaNuts on December 05, 2007, 03:46:46 PM
Wacky. Why not a general operator that returns the value at a specified backwards position in the stack?

like:
{a b c d e f}

3 return = value d
5 return = value b

But then, evolved DNA may lose the little sequencial readability it had.

I suspect a forward-only GoTo could be more straightforward for flow forking. And it would be a lovely retro addition, too.  

I betcha, someday we will be able to code Emacs in DB DNA.
Title: dupbool
Post by: Gobo on December 05, 2007, 03:50:48 PM
Quote from: MacadamiaNuts
I suspect a forward-only GoTo could be more straightforward for flow forking. And it would be a lovely retro addition, too.  
Foo! If you head on DNA readability, goto is perhaps the thing you want the least
Title: dupbool
Post by: Numsgil on December 05, 2007, 03:54:10 PM
An over operator is starting to push the boundary a bit.  Can you achieve the same effect using swap and dup somehow?  If it's really impossible to do using other operators, we might need to implement it, but I'm really leaning towards no on this.  Evolved DNA can get really wacky, so it's best to keep the language as straightforward as possible.

The good news is that for DB3, I'm implementing codules, which would (should) easily allow forking.
Title: dupbool
Post by: Gobo on December 05, 2007, 04:00:11 PM
Quote from: Numsgil
An over operator is starting to push the boundary a bit.  Can you achieve the same effect using swap and dup somehow?
I believe no.
Title: dupbool
Post by: EricL on December 05, 2007, 04:49:25 PM
You can do it for the integer stack this way I think.

swapint dupint 55 store swapint *55

This works because we have temporary places to store integers.  So if we use a mem location to store boolean values:


swapbool dupbool
1 55 store
dropbool
swapbool
*55 1 =

Then I think this works in gene bodies at least...
Title: dupbool
Post by: EricL on December 05, 2007, 04:56:40 PM
swapbool
1 55 store
swapbool
*55 1 =

even shorter...
Title: dupbool
Post by: Gobo on December 05, 2007, 05:28:03 PM
Sure, you can do that with memory allocation. You can even do swapint with memory. But that takes energy.
Title: dupbool
Post by: Numsgil on December 05, 2007, 05:35:11 PM
I'm really on the fence on this.  On the one hand, it's a nice operator in that it operates on just the top two values on the stack-- meaning it's a binary operator.  It easily fits in with other commands like swap, etc.

On the other hand, it provides some really weird possibilities for nonsensical DNA.
Title: dupbool
Post by: EricL on December 05, 2007, 05:41:19 PM
I vote for it.  A user is requesting it.  It's rational.  It's easy to implement.  Sanger can use it.  Hand coded bots too.  It provides a one step way to evolve a potentially useful operation that otherwise takes at least 8 base pairs.  And we are well beyond the point IMHO of worrying departing from a RISC approach to DNA oeprators....  

So, unless there are strong objections...
Title: dupbool
Post by: Gobo on December 05, 2007, 05:41:30 PM
Quote from: Numsgil
On the other hand, it provides some really weird possibilities for nonsensical DNA.
Examples?
P. S. Methinks nonsensical DNA is already provided with not less really weird possibilities
Title: dupbool
Post by: Numsgil on December 05, 2007, 05:50:35 PM
I don't have any good examples.  Ignore the crazy old neophobic man   It's easily rationalized if you extend the thinking of the stack as an "on board" value with one "at bat".  Or in other words, it's just an extension of dup.
Title: dupbool
Post by: EricL on December 05, 2007, 07:04:05 PM
overint
overbool

added in 2.43v.
Title: dupbool
Post by: Sprotiel on December 05, 2007, 07:19:21 PM
I'd really prefer all XXint commands to be named simply XX. It seems to me that by default commands operate on the integer stack, there's no need to overspecify.
Title: dupbool
Post by: EricL on December 05, 2007, 07:29:49 PM
Quote from: Sprotiel
I'd really prefer all XXint commands to be named simply XX. It seems to me that by default commands operate on the integer stack, there's no need to overspecify.
Fine.  I added synonyms for all of them.  over and overint et. al. are now equivalent in DNA files.  Retokinized DNA (like that displayed in the bot properties dialog) uses the short version.