DarwinBotsManual
Open the app EspañolES

All operators

OperatorFamilyWhat it does
<numero>Numbers and readsA number written in the DNA, or the name of a sysvar without an asterisk, is pushed as is onto the integer stack.
*<numero> | *.<sysvar>Numbers and readsAn asterisk attached to a number or a sysvar pushes the contents of that memory cell: it's how you read the senses and your own variables.
addBasicAdds the top two numbers of the integer stack and leaves the result.
subBasicSubtracts the top number of the stack from the one below it: a b sub leaves a − b.
multBasicMultiplies the top two numbers of the integer stack; if the product goes over 2 billion, it stays at that cap.
divBasicDivides the lower number by the top one and rounds to the nearest integer (to the even one on a tie); dividing by zero gives 0.
rndBasicReplaces the top number of the stack with a random one between 0 and that number, both included.
*BasicReads memory at a computed address: pops an address from the stack and pushes what is in that cell.
modBasicLeaves the remainder of dividing the lower number by the upper one, with the sign of the dividend; with divisor 0 it gives 0.
sgnBasicReplaces the top number of the stack with its sign: −1 if negative, 0 if zero and 1 if positive.
absBasicReplaces the number on top of the stack with its absolute value: it strips the sign.
dupBasicDuplicates the number on top of the integer stack, to use it twice without reading or computing it again.
dropBasicPops the number on top of the integer stack and discards it.
clearBasicEmpties the integer stack in one go; it does not touch the boolean stack.
swapBasicSwaps the top two numbers of the integer stack: a b swap leaves b a.
overBasicCopies the second number of the integer stack to the top: a b over leaves a b a.
angleAdvancedGives the angle from the bot to a point x y, in the same units as .aim: ready to store in .setaim.
distAdvancedGives the straight-line distance from the bot to a point x y.
ceilAdvancedSets a ceiling: of the top two numbers on the stack it leaves the smaller, so x 100 ceil never goes above 100.
floorAdvancedSets a floor: of the top two numbers on the stack it leaves the larger, so x 0 floor never goes below 0.
sqrAdvancedReplaces the top number of the stack with its rounded square root; if it isn't positive, it gives 0.
powAdvancedRaises the lower number to the power of the upper one: 2 10 pow gives 1024. The exponent is limited to ±10.
pythAdvancedGives the hypotenuse of the top two numbers of the stack, the square root of a² + b²: the length of a vector.
anglecmpAdvancedCompares two angles and gives the shortest difference between them, signed, between −628 and 628: how much and which way to turn.
rootAdvancedGives the b-th root of the lower number: 27 3 root gives 3. It ignores signs and, with b at 0, gives 0.
logxAdvancedGives the logarithm of the lower number in the base of the upper one, rounded: 1000 10 logx gives 3.
sinAdvancedGives the sine of an angle in .aim units, multiplied by 32000: 314 sin gives 32000.
cosAdvancedGives the cosine of an angle in .aim units, multiplied by 32000: 0 cos gives 32000.
debugintAdvancedNotes the number on top of the integer stack so you can look at it from the bot's console, without popping it and at no cost.
debugboolAdvancedNotes the value on top of the boolean stack so you can look at it from the bot's console, at no cost.
~BitwiseInverts all the bits of the number on top: x ~ leaves −x − 1, so 5 ~ gives −6 and 0 ~ gives −1.
&BitwiseBitwise and of the top two numbers: keeps only the bits that are set in both. Good for checking and clearing flags.
|BitwiseBitwise or of the top two numbers: leaves set every bit that is set in either one. Good for setting flags.
^BitwiseBitwise exclusive or of the top two numbers: leaves a number whose set bits are those in only one of the two. Good for flipping flags.
++BitwiseAdds 1 to the number on top of the integer stack, without touching memory: 5 ++ leaves 6.
--BitwiseSubtracts 1 from the number on top of the integer stack, without touching memory: 5 -- leaves 4 and 0 -- leaves −1.
-BitwiseA loose minus sign flips the sign of the top number: 5 - leaves −5. It doesn't subtract; for that there is sub.
<<BitwiseShifts the bits of the top number one place to the left, that is, multiplies it by 2: 5 << leaves 10.
>>BitwiseShifts the bits of the top number one place to the right, keeping the sign: it divides by 2 rounding down, so 7 >> leaves 3 and −5 >> leaves −3.
<Comparisonsa b < leaves true if a is less than b. The comparison for “hasn't reached yet”.
>Comparisonsa b > leaves true if a is greater than b. The one in *.eye5 0 >, “I see something”.
=Comparisonsa b = leaves true if the two numbers are equal. The one in *.eye5 0 =, “I see nothing”.
!=Comparisonsa b != leaves true if the two numbers are different. The one in *.refeye *.myeye !=, “it is not one of mine”.
%=Comparisonsa b %= leaves true if b is within 10% of a, limits included. With a negative a it is always false.
!%=Comparisonsa b !%= leaves true if b strays more than 10% from a. It is the exact negation of %=, so with negative a it is always true.
~=Comparisonsa b d ~= leaves true if b is within d % of a: an “about equal” with the margin you choose. Pops three numbers.
!~=Comparisonsa b d !~= leaves true if b strays more than d % from a. It is the negation of ~= and also pops three numbers.
>=Comparisonsa b >= leaves true if a is greater than or equal to b: like >, but the limit counts too.
<=Comparisonsa b <= leaves true if a is less than or equal to b: like <, but the limit counts too.
andLogicReplaces the top two values of the boolean stack with one: true only if both are.
orLogicReplaces the top two values of the boolean stack with one: true if either is. The only way to ask for “this or that”.
xorLogicReplaces the top two values of the boolean stack with one: true if exactly one of the two is.
notLogicInverts the top value of the boolean stack: true becomes false and false becomes true. On an empty stack it gives false.
trueLogicPushes a true onto the boolean stack. Inside a gene's body, it re-enables the stores that a condition had blocked.
falseLogicPushes a false onto the boolean stack. In a gene's condition it turns it off; in the body it blocks the stores that follow.
dropboolLogicPops and discards the value on top of the boolean stack. Inside the body, it ends the effect of an inline condition.
clearboolLogicEmpties the boolean stack. Since empty counts as true, every store that follows writes again.
dupboolLogicDuplicates the value on top of the boolean stack. Good for saving a condition and using it again, for example to nest conditions in the body.
swapboolLogicSwaps the top two values of the boolean stack. It lets you compute two conditions and choose which one rules each stretch of the body.
overboolLogicPushes a copy of the second value of the boolean stack: a b becomes a b a. With a single value it pushes true.
storeWriting to memoryStores a number at a memory address: it's how every command is given, like 20 .up store to move forward.
incWriting to memoryAdds 1 to a memory cell: the cheapest counter in the DNA.
decWriting to memorySubtracts 1 from a memory cell: the cheap way to keep a countdown.
addstoreWriting to memoryAdds a number to what is already in a cell, without having to read it first.
substoreWriting to memorySubtracts a number from what's already in a cell: the cell minus the value.
multstoreWriting to memoryMultiplies what's in a cell by a number and stores the result right there.
divstoreWriting to memoryDivides what is in a cell by a number, rounding to the nearest integer; dividing by 0 leaves the cell at 0.
ceilstoreWriting to memoryPuts a ceiling on a cell: if what it holds is greater than the number, it lowers it to that number.
floorstoreWriting to memoryPuts a floor under a cell: if what it holds is smaller than the number, it raises it to that number.
rndstoreWriting to memoryReplaces what's in a cell with a random number between 0 and that value, with the same sign.
sgnstoreWriting to memoryReplaces what's in a cell with its sign: −1 if negative, 0 if zero, 1 if positive.
absstoreWriting to memoryStrips the sign from what is in a cell: a negative becomes positive.
sqrstoreWriting to memoryReplaces what's in a cell with its rounded square root; if it isn't positive, it leaves it at 0.
negstoreWriting to memoryFlips the sign of what's in a cell: 20 becomes −20 and −20 becomes 20.
condFlowOpens a new gene: empties the boolean stack and starts the condition section, which ends at start or else.
startFlowCloses the gene's conditions and opens its body, which runs if all of them came out true; with no cond before it, it always runs.
elseFlowOpens the alternative body of a gene, which runs when the conditions of the cond came out false.
stopFlowCloses the gene: whatever follows, up to the next marker, is not executed.
endFlowEnds the DNA: whatever comes after it does not run. The engine adds one at the end if you do not.