Difference between revisions of "Logic"

From WikiManual
Jump to: navigation, search
m (Fixed typos)
 
(3 intermediate revisions by one other user not shown)
Line 2: Line 2:
  
 
===Logic:===
 
===Logic:===
Logic operators compare two variables on the stack and replace them with a 0 or a 1 on the stack depending on what operator was used and how many of the variables have ben 0.
+
Logic operators perform boolean operations on values on the boolean stack, popping them off the stack in the process and pushing the result onto the stack, either true or false.  The result obviously depends upon the boolean operator used and the values on the stack at the time.
  
All (but [[not]]) return a 1 if at least one of both variables on the stack was not 0.
+
As of version 2.43q, boolean operations can be performed in both the conditional and body portions of a gene.  Commands which modify bot memory (store, inc and dec) will only succeed if the top of the boolean stack is true at the time the memory operation is attempted.
The choosen logic operator mostly exists for situations if both variables are 0 or both are not 0 or if only one of them is 0.
 
{{Is that true?}}
 
  
 
===Energy Cost:===
 
===Energy Cost:===
Since version: 2.4 you can set an Energy cotst per bitwise command instance. default is 0.
+
As of version 2.4, you can set the Energy cost per logic command executed if you so choose. The default cost is 0.

Latest revision as of 22:09, 14 February 2014

Logic:

true
false
and
or
not
xor

Logic:

Logic operators perform boolean operations on values on the boolean stack, popping them off the stack in the process and pushing the result onto the stack, either true or false. The result obviously depends upon the boolean operator used and the values on the stack at the time.

As of version 2.43q, boolean operations can be performed in both the conditional and body portions of a gene. Commands which modify bot memory (store, inc and dec) will only succeed if the top of the boolean stack is true at the time the memory operation is attempted.

Energy Cost:

As of version 2.4, you can set the Energy cost per logic command executed if you so choose. The default cost is 0.