Darwinbots Forum
Code center => Suggestions => Topic started 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.
-
dupbool would do what exactly? Push another value onto the stack that is the same as the top value?
-
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.
-
Me neither. I'll add it in 2.43v.
-
While you're adding operators, a swap had been requested once upon a time. And then go ahead and add a boolswap, too.
-
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?
-
right.
-
dupbool
swapbool
dupint
swapint
added for 2.43v. Names chosen by convention with other stack operators.
-
Thanks. BTW,
dupint
was known as dup. Is it considered alias now?
-
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).
-
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:
if ( A ) {
if ( B ) {
C
}
else {
D
}
}
else {
E
}
could be then coded as:
A dupbool B overbool overbool and C dropbool not and D dropbool not E dropbool
-
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.
-
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
-
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.
-
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.
-
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...
-
swapbool
1 55 store
swapbool
*55 1 =
even shorter...
-
Sure, you can do that with memory allocation. You can even do swapint with memory. But that takes energy.
-
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.
-
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...
-
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
-
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.
-
overint
overbool
added in 2.43v.
-
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.
-
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.