DarwinBotsManual
Open the app EspañolES

inc

Adds 1 to a memory cell: the cheapest counter in the DNA.

Facts

Word
inc
Family
Writing to memory
Integer stack
pops 1, pushes 0
What it does
Pops an address and adds 1 to that cell. Past 32000 it wraps back to 1. With address 0 it does nothing.
Cost
Store divided by the divisor of each one, only if it writes
Cost divisor
÷ 10
Runs
in the body of a gene (start or else), and only if the top of the boolean stack is true or the stack is empty
Marks ties
no

d inc pops the address d and adds 1 to whatever is in that cell. It takes no value from the stack: 50 inc is the same as *50 1 add 50 store, but in two words and for a tenth of the cost of a store.

WordStack afterwards
5050
inc(empty); cell 50 holds one more

The typical use is counting cycles in free memory, which is not cleared between one cycle and the next:

' counts cycles in cell 50 and turns every 10
start
 50 inc
stop
cond
 *50 10 >=
start
 0 50 store
 100 .aimdx store
stop

Cell 50 goes from 1 to 9; in the tenth cycle it reaches 10, the second gene sets it back to 0 and the bot turns 100 with .aimdx. So it turns once every 10 cycles.

Two things to keep in mind:

To subtract 1 there is dec; to add another amount, addstore.