Code center > Suggestions

Gene structure - cond start stop

<< < (5/10) > >>

Peksa:
Looks very nice!

Just to check, if I understood this completely, would this work?

start
*.body *.nrg >
*.nrg 500 >
50 .strbody store
and
-50 .strbody store
stop


EDIT:
Oh, what about else? Would this work?

start
*.eye5 50 >
.shoot dec
else
314 rnd .aimsx store
stop

EricL:

--- Quote from: Peksa ---Just to check, if I understood this completely, would this work?
--- End quote ---

' Cooments below


start                 ' No cond section.  If stores followed this, their success would depend on boolean logic above
*.body *.nrg >        'Result of this is pushed on boolean stack.  Call it A.
*.nrg 500 >            'Result of this is pushed on boolean stack.  Call it B
50 .strbody store    ' store will occcur if B is True.  Will not if B is False.  There is no implicit AND of A and B
and                       'A is ANDed with B.  Result is pushed on Boolean stack.
-50 .strbody store  ' This store will happen if A AND B is True.
stop


--- Quote from: Peksa ---EDIT:
Oh, what about else? Would this work?
--- End quote ---

start
*.eye5 50 >                ' Call this C
.shoot dec                   ' happens if C is true
else
314 rnd .aimsx store   ' Never happens.  Currently Else applies only to Cond section, which is missing here.
stop


But the same running boolean state works within else statements.  For example:


cond
false
start
1 *50 store
else
2 *50 store
2 1 <
3 *50 store
stop

memory location 50 will end up with a value of 2.

Gobo:
Is there a way to clear the boolean stack within a gene's body?

EricL:

--- Quote from: Gobo ---Is there a way to clear the boolean stack within a gene's body?
--- End quote ---

There isn't an explicit clear stack command.  A bunch of boolean logic operators which pop values would do it.  Something like 20 OR's for example, enough that you pop whatever is there and bottom the stack out so that the result of the last one is true.  

Another start won't do it.  It clears the stack after a Cond by ANDing it all up, but if the current state is the gene body already, it doesn't do anything.

EDIT:  Adding a Clear command might be usefull....

Numsgil:
I added a general purpose clear command that dumps both stacks to the DNA for Darwinbots 3, so I agree

Not sure if we need a single command for each stack or a single one for both stacks though.

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version