cond
Opens a new gene: empties the boolean stack and starts the condition section, which ends at start or else.
Facts
- Word
cond- Family
- Flow
- What it does
- Closes the previous gene and opens a new one with its condition section. Empties the boolean stack. Everything runs in that section, but the stores do not write.
- Cost
- Flow control; end is free
- Runs
- always
cond opens a gene. From there to the start (or the else) is the condition section: comparisons such as > or = that leave trues and falses on the boolean stack. When start is reached, the body runs only if all of them are true.
' reproduces if it has more than 5000 energy and sees nothing ahead
cond
*.nrg 5000 >
*.eye5 0 =
start
50 .repro store
stopThe two conditions, on .nrg and .eye5, are joined with and without writing anything more; for an or you need or. With 6000 energy the bot divides with .repro in the second cycle, not the first: the senses are published at the end of each cycle and in the first one they are still 0 (see Execution and costs).
What is worth knowing about cond:
- It empties the boolean stack at the start. It is the only marker that always empties it (
start,elseandstopdo so only when they close a condition section), so starting a gene withcondprotects it from conditions left over from before (see The integer and boolean stacks). - In the condition section everything runs except stores: you can calculate, but a
storethere does not write and pops nothing from the stack. - A
condwithout conditions, followed bystart, always runs. - A
condin the middle of a body closes that gene and opens another, even if thestopis missing. - Each
condcounts as a new gene in.genesand.thisgene.
The complete structure of the gene is in Genes: cond, start, else and stop.