DarwinBotsManual
Open the app EspañolES

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
stop

The 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:

The complete structure of the gene is in Genes: cond, start, else and stop.