Darwinbots Forum
Bots and Simulations => DNA - General => Topic started by: MT DNA on September 09, 2009, 02:15:07 AM
-
Here is my code, I have removed everything that doesn't actually pertain to my question to make it more simple to read.
cond
true
'Condition for reproduction
start
*.nrg 500 > mult 10 dropbool
*.nrg 1000 > mult 20 dropbool
*.nrg 4000 > mult 30 dropbool
*.nrg 8000 > mult 40 dropbool
.repro store
.preg inc
stop
Ok now to confirm how I thought it worked. Correct me when I'm wrong (because I must be, 'cause my codes not working)
Cond must be true for any of the DNA from start to stop to execute.
nrg > 500 (true) add 10 to the stack (either way) drop the previous value from the bool stack putting it back to true.
nrg > 500 (true) add 20 to the stack (either way) drop the previous value from the bool stack putting it back to true.
nrg > 500 (true) add 30 to the stack (either way) drop the previous value from the bool stack putting it back to true.
nrg > 500 (true) add 40 to the stack (either way) drop the previous value from the bool stack putting it back to true.
(implied to be true) .repro store .preg inc
The way I've interpreted this is, that my values should only be added to the number stack if true is on the top of the bool stack, but I'm guessing I'm wrong on that. Obviously number have to be able to get on the stack in order for 2 1 > to be evaluated when false is on the stack. However, if thats the case how do I do this and make it right with only one store. I've been trying to keep my code a small and efficient as possible.
Thanks MT
-
Your inline conditions are commented out.
Also, I think they control store, inc, and dec. Not every value push.
-
Cond must be true for any of the DNA from start to stop to execute.
This is not quite true, conditionals will always be evaluated, regardless of the boolean stack. This is what I would do to achieve the same result:
start
*.nrg 500 >
10
*.nrg 1000 >
20
*.nrg 4000 >
30
*.nrg 8000 >
40
true
.repro store
stop
-
Cond must be true for any of the DNA from start to stop to execute.
This is not quite true, conditionals will always be evaluated, regardless of the boolean stack. This is what I would do to achieve the same result:
start
*.nrg 500 >
10
*.nrg 1000 >
20
*.nrg 4000 >
30
*.nrg 8000 >
40
true
.repro store
stop
No the problem is whether or not the conditions are true the values get pushed onto the stack, I think maybe, I'm just going to go with something like
*.nrg 500 >
*.nrg 5000 ceil 100 div
-
I'm pretty sure that the values are pushed onto the stack regardless of the boolean stack. Otherwise new conditions couldn't be evaluated. The boolean stack only affects things like inc, dec, and store. If the boolean stack is false, they still take values from the integer stack but nothing gets written to memory.