Difference between revisions of "Advanced Stack"

From WikiManual
Jump to: navigation, search
m (Pre 2.4)
Line 4: Line 4:
 
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
 
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
cond
+
*.robage 0 =
*.robage 0 =
+
start
start
+
998 rnd 1 add
998 rnd 1 add
+
stopcond
stopcond
+
*.refeye *.myeye !=
*.refeye *.myeye !=
+
*.eye5 50 >
*.eye5 50 >
+
start
start
+
dup .tie store
dup .tie store
+
stop
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.  
 
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.  
Line 22: Line 20:
 
Another more advanced use is to store a whole series of actions into the stack and then unstacking them in the following cycles.
 
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
cond
+
*.robage 0 =
*.robage 0 =
+
start
start
+
50 .repro
50 .repro
+
314 .aimdx
314 .aimdx
+
10 .up
10 .up
+
stop
stop
+
'
 
+
cond
cond
+
start
start
+
dup
dup
+
stop
stop
+
'
 
+
cond
cond
+
0 >
0 >
+
' dup gene and 0 > not really needed in this case but helps to
' dup gene and 0 > not really needed in this case but helps to
+
' demo ability to sense the stack without destroying the information  
' demo ability to sense the stack without destroying the information
+
start
start
+
store
store
+
stop
stop
 
{code}
 
  
 
This will cause the bot to perform the above actions from bottom to top.
 
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.  
+
This could also be used for anything from MB reproduction to more accurate aiming.
 
 
 
 
--------------------------------------------------------------------------------
 
  
 
== Post 2.4 ==
 
== Post 2.4 ==

Revision as of 14:54, 21 December 2005

Pre 2.4

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

cond
*.robage 0 =
start
998 rnd 1 add
stopcond
*.refeye *.myeye !=
*.eye5 50 >
start
dup .tie store
stop

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.

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

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.

Post 2.4

The stack no longer carries values between cycles, making many of these techniques less useful than they were preciously.

Stack