DarwinBotsManual
Open the app EspañolES

!~=

a b d !~= leaves true if b strays more than d % from a. It is the negation of ~= and also pops three numbers.

Facts

Word
!~=
Family
Comparisons
Integer stack
pops 3, pushes 0
Boolean stack
pops 0, pushes 1
What it does
Pops three numbers a b d and pushes true if b is farther than d% from a. If only one of a and d is negative, it is always true.
Cost
Condition
Runs
inside a gene: in the condition (cond) and in the body (start or else)

a b d !~= pops three numbers and pushes true when b is not within d % of a. It is the opposite of ~=: 100 130 25 !~= is true and 100 120 25 !~= is false. The reference is a, the lowest one, and the percentage goes on top.

It's useful for reacting to big changes and ignoring small ones. This bot counts in cell 51 the cycles in which what the middle eye (.eye5) sees changed by more than 5% from the previous cycle, which it keeps in cell 50:

' counts the cycles in which what it sees changed by more than 5%
cond
  *50 *.eye5 5 !~=
start
  51 inc
stop

cond
start
  *.eye5 50 store
stop

Apart from the case of huge numbers explained below, ~= and !~= are complementary: if you put this counter and the one from the page of ~= in the same bot, in each cycle exactly one of the two goes up.

Since it's the negation, it inherits the quirks of ~= in reverse: if the reference or the percentage is negative (only one of the two), it always gives true. And it has a quirk of its own: the computed margin is capped at two billion, which ~= doesn't do. It only matters with enormous numbers, which don't fit in memory; in that case ~= and !~= can both give true at once.

The bot Chaotic Swarm ver 1.2 (SA), from the Bestiary, uses !~= with a 5% margin to decide whether what each eye sees has changed. The version with a fixed 10% is !%=.