Advanced Stack
Saving Values into the Stack The Stack can be used as a means to save a value than retrieve it whenever necessary. The new dup operator allows the number to stay in the Stack continously
{code} cond
- .robage 0 =
start 998 rnd 1 add stopcond
- .refeye *.myeye !=
- .eye5 50 >
start dup .tie store stop {code}
This will duplicate the value and also use it to tie. The same value can then be kept and re-used forever. To use it as part of a condition statement requires a solo "dup" gene.
Timing Actions with the Stack Another more advanced use is to store a whole series of actions into the stack and then unstacking them in the following cycles.
{code} cond
- .robage 0 =
start 50 .repro 314 .aimdx 10 .up stop
cond start dup stop
cond 0 > ' dup gene and 0 > not really needed in this case but helps to ' demo ability to sense the stack without destroying the information start store stop {code}
This will cause the bot to perform the above actions from bottom to top. This could also be used for anything from MB reproduction to more accurate aiming.