DarwinBotsManual
Open the app EspañolES

ceilstore

Puts a ceiling on a cell: if what it holds is greater than the number, it lowers it to that number.

Facts

Word
ceilstore
Family
Writing to memory
Integer stack
pops 2, pushes 0
What it does
Pops an address and a value, and leaves the smaller of the two in the cell: it is a ceiling. With address 0 the value is lost.
Cost
Store divided by the divisor of each one, only if it writes
Cost divisor
÷ 5
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
yes

v d ceilstore leaves in cell d the smaller of what it held and v. If the cell is already below v, it does not change; if it is above, it ends up at v. It is a ceiling, like ceil but applied directly to memory.

WordStack after
3030
.up30 1
ceilstore(empty); .up is at most 30

Since stores are immediate, it is good for trimming a command you already wrote in the same cycle:

' moves forward according to its age, but never asks for more than 30
cond
start
 *.robage .up store
 30 .up ceilstore
stop

In the first cycles the bot asks for 0, 1, 2… with .up, according to its age (.robage); from cycle 31 on it always asks for 30.

The name is a little confusing: “ceil” sounds like rounding up, but here it means ceiling and it keeps the smaller. To set a floor, the larger, there is floorstore. Combined with addstore it makes a capped accumulator (there is an example in addstore).

With address 0 the value is popped from the stack and lost. Like store, it notifies the tie system if you write to .tieang1 or .tielen1.