clear
Empties the integer stack in one go; it does not touch the boolean stack.
Facts
- Word
clear- Aliases
clearint- Family
- Basic
- Integer stack
- pops all, pushes 0
- What it does
- Empties the integer stack. It does not touch the boolean stack.
- Cost
- Basic command
- Runs
- inside a gene: in the condition (cond) and in the body (start or else)
clear throws away everything in the integer stack. You can also write clearint. The boolean stack stays as it was; for that one there is clearbool.
Why empty the stack, if every bot starts its turn with empty stacks? Because between genes of the same cycle the integer stack is not emptied: a number left over in one gene is found by the next. clear at the start of a body makes sure the gene works only with its own values.
start
7
stop
cond
start
clear 50 store
stopThe first gene leaves a forgotten 7. Without the clear, the second gene would store it in cell 50; with the clear, the stack is empty, store pops a 0 and cell 50 ends up at 0. More on this in The integer and boolean stacks.