
ORGANISM INSTRUCTION REFERENCE
The core KFORTH instruction (like dup, pop, +, *, /, etc..) are covered in the section entitled the KFORTH Language. What follows is a detailed reference guide for the instructions that control organisms and cells:
Interacting with the universe:
Vision:
Communicating between cells:
Query information about ourselves:
Universe Instructions:
Misc. instructions:
Interacting with the universe:
INSTRUCTION | USAGE | DESCRIPTION |
CMOVE | ( x y -- r ) | Move the cell that executes this instruction relative to the organism. |
OMOVE | ( x y -- n ) | Move entire organism by one square in the up, down, left, right, or diagonal direction. |
ROTATE | ( n -- r ) | Rotate the organism by 45 degree units around the cell that executes this instruction. The rotate direction is given by
'n'. A positive 'n' rotates the organism clock-wise 45 degrees. A negative 'n' rotates the organism 45 degrees counter-clockwise. If 'n' is zero don't rotate the organism and return 0. |
EAT | ( x y -- n ) | Eat stuff at (x, y) from this cell. Return 'n' the amount of energy eaten. |
SEND-ENERGY | (e x y -- rc) | send the energy to the cell at normalized coordinate (x,y). negative 'e' values take from that cell. If there isn't enough energy to perform the transfer (too little energy compared to 'e')) then don't do anything. |
MAKE-SPORE | ( x y e -- r ) | Create new spore (or fertilize an existing spore). When a spore is fertilized, the original genetic program used to create the spore, and the genetic program from the organism that fertilized the spore will be first merged. Then the resulting genetic program is MUTATED. Then a new organism is born. It will begin execution at the first instruction of code block 0 (main). It will be given 'e' units of energy, which is the sum of the energy specified with the first and second MAKE-SPORE instructions. MAKE-SPORE Energy: This setting is available on the Strain Modes tab. The value represents the minimum amount of energy required to create a spore. If 'e' is not big enough, then this instruction will return 0. A minimum of '1' units of energy is always required to create the initial spore. |
GROW | ( x y -- r ) | Add a new cell to this organism. The new cell inherits the data stack, call stack and registers of the parent cell. The parent and child can check the return value to determine which one they are. GROW Energy: This field is available on the Strain Modes tab. It sets the minimum amount of energy required to grow a cell. Each organism has a total amount of energy. If total energy divided by the number of cells isn't equal or greater to this value, then the GROW operation will fail. GROW Max Size: This field is available on the Strain Modes tab. It sets the maximum number of cells that an organism can be. If this value is 0, then there is no maximum. |
MAKE-ORGANIC | (x y e -- s) | Create organic block at (x,y) offset with energy e. |
GROW.CB | (x y cb -- r) | Grow a new cell at (x,y) normalized offset. The new cell inherits the context of the cell which executed the GROW.CB instruction. However, it will begin execution at code block 'cb'. Respects the Grow Max Size setting. If the number of cells is already at the max size, then GROW.CB will not succeed. Unprotected code cannot specify a protected code block number for cb. |
CSHIFT | (x y -- r) | This instruction is similar to CMOVE except a group of cells move (or shift position in space) along a vector. If the shape of the organism after the CSHIFT operation would violate the connectivity of the organism then this instruction fails. |
SPAWN | (x y e strain cb -- r) | Spawn a new organism at the (x,y) normalized offset. Give it 'e' units of energy. Start running at code block 'cb. The identity of the new organism will be strain 'strain'. The cellular state of the spawned organism will inherit the cell executing this instruction. Unprotected code cannot specify a protected code block number for cb. |
MAKE-BARRIER | (x y -- r) | Creates a barrier block at the x y normalized offet. If the location already contains a barrier block, then this instruction will clear the barrier. |
EXUDE | (value x y -- ) | excrete a value onto the grid |
SMELL | (x y -- value) | read a value from the grid that was previously EXUDE'd. |
Vision:
INSTRUCTION | USAGE | DESCRIPTION |
LOOK | ( x y -- what dist ) | Look along a normalized (x, y) direction vector. Return the thing it found, and the distance. NOTE: The LOOK Mode settings apply to all the vision instructions such as NEAREST / FARTHEST, HOTTEST / COLDEST, and SMALLEST / BIGGEST. |
NEAREST | ( mask -- x y ) | Looks in all 8 directions and return the (x, y) direction vector that corresponds to the thing with the smallest
distance (and matches a 'mask' value). The returned (x,y) vector is not normalized, so it might return (-6,6) instead of
(-1,1). mask values are the same as what values. If any bit matches the what from LOOK'ing along that vector then we match.
|
FARTHEST | ( mask -- x y ) | Looks in all 8 directions and return the (x, y) direction vector that corresponds to the thing with the largest
distance (and matches a 'mask' value). The returned (x,y) vector is not normalized, so it might return (-6,6) instead of
(-1,1). mask values are the same as what values. If any bit matches the what from LOOK'ing along that vector then we match.
|
SIZE | (x y -- size dist) | Report the size (number of cells) of the object seen along the normalized vector (x,y) from this cell. |
BIGGEST | (mask -- x y) | Look in all 8 directions. Return a non-normalized (x,y) vector to the biggest thing. This is the organism consisting of
the most number of cells. The returned (x,y) vector is not normalized, so it might return (-6,6) instead of (-1,1).
mask values are the same as what values. If any bit matches the what from LOOK'ing along that vector then we match.
This instruction also uses the LOOK Mode bits. |
SMALLEST | (mask -- x y) | Look in all 8 directions. Return a non-normalized (x,y) vector to the smallest thing. This is the organism with the
least number of cells. The returned (x,y) vector is not normalized, so it might return (-6,6) instead of (-1,1). mask values are the same as what values. If any bit matches the what from LOOK'ing along that vector then we match.
This instruction also uses the LOOK Mode bits. |
TEMPERATURE | (x y -- energy dist) | Get the energy of cell seen along (x,y). This is per cell. For organisms we divide the total energy the organism has by the number of cells the organism has. |
HOTTEST | (mask -- x y) | Look in all 8 directions. Return a non-normalized (x,y) vector to the hottest thing. This is the organism with the
most energy per cell. The returned (x,y) vector is not normalized, so it might return (-6,6) instead of (-1,1). mask values are the same as what values. If any bit matches the what from LOOK'ing along that vector then we match.
This instruction also uses the LOOK Mode bits. |
COLDEST | (mask -- x y) | Look in all 8 directions. Return a non-normalized (x,y) vector to the coldest thing. This is the organism with the
least energy per cell. The returned (x,y) vector is not normalized, so it might return (-6,6) instead of (-1,1). mask values are the same as what values. If any bit matches the what from LOOK'ing along that vector then we match.
This instruction also uses the LOOK Mode bits. |
Communicating between cells:
INSTRUCTION | USAGE | DESCRIPTION |
MOOD | ( x y -- m ) | Every cell has its own "MOOD" register. This instruction queries another cell using an (x, y) vector. This vector is not normalized which allows the cell to query any other cell within its own organism (not just adjacent cells). For example, if cell 2 executed the following instructions: 0 0 MOOD ; returns -23 -1 0 MOOD ; returns 123 -1 1 MOOD ; returns 33 99 99 MOOD ; returns 0 If a bogus (x, y) is specified then 0 is pushed on the data stack. We can query our own mood by specifying (0, 0). |
MOOD! | ( m -- ) | The cell executing this instruction will set its own mood register. It is not possible to set others. The purpose of the mood register is for a cell it advertise its "mood" to other cells in the organism. For example, if cell 3 executed these instructions: 0 0 MOOD 1 + MOOD! Then cell 3's mood would be increased by 1. So it would be set to 34. |
BROADCAST | ( m -- ) | This instruction takes the value off of the top of the data stack and sets the message register for every cell in our organism. If interrupts are enabled every cell, except the cell executing this instruction, will be interrupted. |
SEND | ( m x y -- ) | This instruction takes 3 arguments. An (x, y) vector and a value 'm'. The vector is NOT normalized so that the cell can send a message 'm' to any other cell in the same organism (not just adjacent cells). For example, if cell 1 exectuted this these two instructions: 100 1 0 SEND ; set cell 2's message register to 100 -46812 0 1 SEND ; set cell 3's message register to -46812 0 0 0 SEND ; set out message register to 0. 12 -99 99 SEND ; does nothing because (-99, 99) is bogus A SEND operation using bogus coordinates will be ignored. |
RECV | ( -- m ) | The RECV instruction just pushes a copy of our message register on top of the data stack. |
SHOUT | (m -- r) | Broadcast a message to another organism. Send the message 'm' outward in all 8 directions. If a cell is reached, then set it's MESSAGE register to be 'm'. |
SAY | (m x y -- dist) | The (x,y) normalized direction vector will be used to send the message 'm'. If a cell is reached, then set it's MESSAGE register to be 'm'. |
LISTEN | (x y -- mood dist) | Listen along the normalized vector (x,y). If another cell was found return its MOOD register and distance. |
READ | (x y cb cbme -- rc) | Read code block 'cb' from the cell or spore located at the normalized (x,y) coordinates. Place the result into 'cbme'.
It is not possible to grow the number of code blocks of a program with this instruction. The destination code
block 'cbme' must already exist. Unprotected code cannot READ if 'cb' or 'cbme' is protected. Unprotected code cannot read a protected instruction. |
WRITE | (x y cb cbme -- rc) | Write code block 'cbme' to another cell or spore. The cell is located at the normalized (x, y) offset from
this cell. The destination code block number is given by 'cb'. It is not possible to grow the number of
code blocks of a program. The destination code block 'cb' must already exist. Unprotected code cannot WRITE if 'cb' or 'cbme' is protected. Unprotected code cannot write a protected instruction. |
Query information about ourselves:
INSTRUCTION | USAGE | DESCRIPTION |
ENERGY | ( -- e ) | Get our organisms overall energy. |
AGE | ( -- a ) | Fetch the organisms "age" field (which is the number of elapsed simulation step) and push this value on our data stack. |
NUM-CELLS | ( -- n ) | Push the number of cells that comprise this organism on our data stack. |
HAS-NEIGHBOR | ( x y -- r ) | Determine if a neighboring cell location contains our cell or not. |
NEIGHBORS | ( -- mask) | Returns a bitmask with a '1' bit set for a neighor in that direction. |
GPS | ( -- x y) | Returns the absolute grid coordinates for the cell executing this instruction. |
Universe Instructions:
INSTRUCTION | USAGE | DESCRIPTION |
G0 | ( -- value) | Get universe-wide global variable. This is a common global that all CELL's can query with this instruction. |
G0! | (value -- ) | Set universe-wide global variable. This is a common global that all CELL's can write to with this instruction. |
S0 | ( -- value) | Get strain-wide global variable. Each strain has its own S0 global variable. This instruction allows the strain specific variable to
be queried. This variable can be used by a swarm of organisms, from the same strain, to coordinate their activies. |
S0! | (value -- ) | Set strain-wide global variable. Each strain has its own S0 global variable. This instruction allows the strain specific variable to
be written to. This variable can be used by a swarm of organisms, from the same strain, to coordinate their activies. |
POPULATION | ( -- pop) | Return the current population. |
POPULATION.S | ( -- pop) | Return the current population of my strain. |
KEY-PRESS | ( -- key) | Get the keyboard character being pressed. Or 0 if nothing is being pressed. |
MOUSE-POS | ( -- x y) | Query the mouse position. The mouse position is a coordinate in the universe coordinate space. This position was set externally by the user right clicking on a grid location when in 'MOUSE-POS' mode. See the KEY-PRESS instruction modes to configure interrupts for the mouse position. |
Misc. instructions:
INSTRUCTION | USAGE | DESCRIPTION |
DIST | (x y -- dist) | Computes the maximum of ABS(x) and ABS(y). |
CHOOSE | (min max -- rnd) | pick random value between two values |
RND | ( -- rnd) | return random value between MIN_INT and MAX_INT. |
CMOVE
Usage: ( x y -- r )move a cell relative to the organism
Move the cell that executes this instruction relative to the organism.
- If there are not 2 elements on the data stack, then skip this instruction.
- Remove the (x, y) coordinates from the stack.
- Normalize the coordinates.
- Examine the destination square (as indicated by the offsets) and see if it is vacant. If not, return 0.
- Check that the organism is propery connected after the move. If not return 0.
- Else, Move the cell to the new location and return 1.
- A CMOVE of (0,0) always fails and returns 0.
RETURNS:
- 0 - cell could not be moved.
- 1 - success.
ENERGY: Does not require any energy.
CMOVE MODE BITS:
BIT | MASK | Meaning when bit is 0 | Meaning when bit is 1 |
0 | 1 | NOT USED | NOT USED |
move entire organism Move entire organism by one square in the up, down, left, right, or diagonal direction. RETURNS: ENERGY: Does not require any energy. OMOVE MODE BITS: rotate organism Rotate the organism by 45 degree units around the cell that executes this instruction. The rotate direction is given by
'n'. A positive 'n' rotates the organism clock-wise 45 degrees. A negative 'n' rotates the organism 45 degrees counter-clockwise.
If 'n' is zero don't rotate the organism and return 0.
RETURNS: ENERGY: Does not require any energy. ROTATE MODE BITS: eat energy from surrounding cells Eat stuff at (x, y) from this cell. Return 'n' the amount of energy eaten. RETURNS: ENERGY: Does not require any energy. EAT MODE BITS: give/take energy to neighboring cell send the energy to the cell at normalized coordinate (x,y). negative 'e' values take from that cell. If there isn't
enough energy to perform the transfer (too little energy compared to 'e')) then don't do anything. RETURNS: Returns the number of units of energy given/taken. 0 is returned if the operation failed. ENERGY: SEND-ENERGY MODE BITS: create spore and reproduce Create new spore (or fertilize an existing spore).
When a spore is fertilized, the original genetic program used to create the spore, and the genetic program from the
organism that fertilized the spore will be first merged. Then the resulting genetic program is MUTATED. Then a new organism
is born. It will begin execution at the first instruction of code block 0 (main). It will be given 'e' units of energy, which is the sum of the energy specified with the first and second MAKE-SPORE instructions.
MAKE-SPORE Energy: This setting is available on the Strain Modes tab. The value represents the minimum amount of energy required to
create a spore. If 'e' is not big enough, then this instruction will return 0. A minimum of '1' units
of energy is always required to create the initial spore.
RETURNS: ENERGY: Requires 'e' units of energy. MAKE-SPORE MODE BITS: add a new cell to the organism
Add a new cell to this organism. The new cell inherits the data stack, call stack and registers of the
parent cell. The parent and child can check the return value to determine which one they are.
GROW Energy: This field is available on the Strain Modes tab. It sets the minimum amount of energy required to grow
a cell. Each organism has a total amount of energy. If total energy divided by the number of cells isn't
equal or greater to this value, then the GROW operation will fail.
GROW Max Size: This field is available on the Strain Modes tab. It sets the maximum number of cells that an organism
can be. If this value is 0, then there is no maximum.
RETURNS: ENERGY: Requires GROW Energy units of energy. GROW MODE BITS: create organic block Create organic block at (x,y) offset with energy e. RETURNS: 0 Returns the amount of energy that was d ENERGY: The energy 'e' is deducted from the organisms (or cells) energy. MAKE-ORGANIC MODE BITS: grow another cell Grow a new cell at (x,y) normalized offset. The new cell inherits the context of the cell which executed the
GROW.CB instruction. However, it will begin execution at code block 'cb'. Respects the Grow Max Size setting. If the number of cells
is already at the max size, then GROW.CB will not succeed. Unprotected code cannot specify a protected code block number
for cb. RETURNS: ENERGY: Respects the Grow Energy setting. If adding this cell would cause the total amount of energy per cell to drop below
the Grow Energy amount, then GROW.CB fails. shift a line of cells relative to the organism This instruction is similar to CMOVE except a group of cells move (or shift position in space) along a vector.
If the shape of the organism after the CSHIFT operation would violate the connectivity of the organism then this instruction
fails. RETURNS: Returns the number of cells that shifted. ENERGY: Does not require energy. CSHIFT MODE BITS: spawn a new organism of a particular strain Spawn a new organism at the (x,y) normalized offset. Give it 'e' units of energy. Start running at code block
'cb. The identity of the new organism will be strain 'strain'. The cellular state of the spawned organism will inherit
the cell executing this instruction. Unprotected code cannot specify a protected code block number for cb. RETURNS: returns 1 if the spawn was successful, else 0. ENERGY:'e' units of energy are required. SPAWN MODE BITS: create (or clear) a barrier block Creates a barrier block at the x y normalized offet. If the location already contains a barrier block, then this
instruction will clear the barrier. RETURNS: ENERGY: MAKE-BARRIER MODE BITS: excrete a value onto the grid excrete a value onto the grid RETURNS: ENERGY: EXUDE MODE BITS: read a value from the grid read a value from the grid that was previously EXUDE'd. RETURNS: ENERGY: look along a line Look along a normalized (x, y) direction vector. Return the thing it found, and the distance.
NOTE: The LOOK Mode settings apply to all the vision instructions such as NEAREST / FARTHEST, HOTTEST / COLDEST, and SMALLEST
/ BIGGEST.
RETURNS:
What values:
ENERGY: Does not use energy. LOOK MODE BITS: find nearest object Looks in all 8 directions and return the (x, y) direction vector that corresponds to the thing with the smallest
distance (and matches a 'mask' value). The returned (x,y) vector is not normalized, so it might return (-6,6) instead of
(-1,1).
mask values are the same as what values. If any bit matches the what from LOOK'ing along that vector then
we match.
RETURNS: ENERGY: Does not use energy. find farthest object Looks in all 8 directions and return the (x, y) direction vector that corresponds to the thing with the largest
distance (and matches a 'mask' value). The returned (x,y) vector is not normalized, so it might return (-6,6) instead of
(-1,1).
mask values are the same as what values. If any bit matches the what from LOOK'ing along that vector then
we match.
RETURNS: ENERGY: Does not use energy. see the size of something Report the size (number of cells) of the object seen along the normalized vector (x,y) from this cell. RETURNS: The number of cells (the 'size') in the organism seen along (x,y). Also returns the distance. ENERGY: find the biggest thing in view Look in all 8 directions. Return a non-normalized (x,y) vector to the biggest thing. This is the organism consisting of
the most number of cells. The returned (x,y) vector is not normalized, so it might return (-6,6) instead of (-1,1).
mask values are the same as what values. If any bit matches the what from LOOK'ing along that vector then
we match.
This instruction also uses the LOOK Mode bits.
RETURNS: ENERGY: find the smallest thing in view Look in all 8 directions. Return a non-normalized (x,y) vector to the smallest thing. This is the organism with the
least number of cells. The returned (x,y) vector is not normalized, so it might return (-6,6) instead of (-1,1).
mask values are the same as what values. If any bit matches the what from LOOK'ing along that vector then
we match.
This instruction also uses the LOOK Mode bits.
RETURNS: ENERGY: get the energy of cell seen along (x,y) Get the energy of cell seen along (x,y). This is per cell. For organisms we divide the total energy the
organism has by the number of cells the organism has. RETURNS: ENERGY: find the most energetic cell in view Look in all 8 directions. Return a non-normalized (x,y) vector to the hottest thing. This is the organism with the
most energy per cell. The returned (x,y) vector is not normalized, so it might return (-6,6) instead of (-1,1).
mask values are the same as what values. If any bit matches the what from LOOK'ing along that vector then
we match.
This instruction also uses the LOOK Mode bits.
RETURNS: ENERGY: find the least energetic cell in view Look in all 8 directions. Return a non-normalized (x,y) vector to the coldest thing. This is the organism with the
least energy per cell. The returned (x,y) vector is not normalized, so it might return (-6,6) instead of (-1,1).
mask values are the same as what values. If any bit matches the what from LOOK'ing along that vector then
we match.
This instruction also uses the LOOK Mode bits.
RETURNS: ENERGY: Query the MOOD of one of my cells
Every cell has its own "MOOD" register. This instruction queries another cell using an (x, y) vector. This vector is not normalized which allows the cell to query any other cell within its own organism (not just adjacent cells). For example, if
cell 2 executed the following instructions:
If a bogus (x, y) is specified then 0 is pushed on the data stack. We can query our own
mood by specifying (0, 0).
RETURNS: ENERGY: Does not use energy. Set MOOD register to a value
The cell executing this instruction will set its own mood register. It is not possible to set others. The purpose
of the mood register is for a cell it advertise its "mood" to other cells in the organism. For example,
if cell 3 executed these instructions:
Then cell 3's mood would be increased by 1. So it would be set to 34.
RETURNS: ENERGY: Does not use energy. broadcast a message to our cells This instruction takes the value off of the top of the data stack and sets the message register for every
cell in our organism. If interrupts are enabled every cell, except the cell executing this instruction, will be interrupted. RETURNS: ENERGY: Does not use energy. BROADCAST MODE BITS: Set the MESSAGE register of one of my cells
This instruction takes 3 arguments. An (x, y) vector and a value 'm'. The vector is NOT normalized so that the cell
can send a message 'm' to any other cell in the same organism (not just adjacent cells). For example, if
cell 1 exectuted this these two instructions:
A SEND operation using bogus coordinates will be ignored.
RETURNS: ENERGY: Does not use energy. SEND MODE BITS: recieve message The RECV instruction just pushes a copy of our message register on top of the data stack. RETURNS: ENERGY: Does not use energy. broadcast a message to another organism Broadcast a message to another organism. Send the message 'm' outward in all 8 directions. If a cell is reached,
then set it's MESSAGE register to be 'm'. RETURNS: The number of cells that recieved the message. ENERGY: SHOUT MODE BITS: send a message along a line to another organism The (x,y) normalized direction vector will be used to send the message 'm'. If a cell is reached, then set
it's MESSAGE register to be 'm'. RETURNS: Returns non-zero on success. The returned value is the distance to the cell that successfully recieved the message, or 0
if no message delivered. ENERGY: SAY MODE BITS: read MOOD register from a cell from another organism Listen along the normalized vector (x,y). If another cell was found return its MOOD register and distance. RETURNS: Returns the mood and distance value, or 0 0 if nothing heard. ENERGY: LISTEN MODE BITS: read an entire code block from another cell or spore Read code block 'cb' from the cell or spore located at the normalized (x,y) coordinates. Place the result into 'cbme'.
It is not possible to grow the number of code blocks of a program with this instruction. The destination code
block 'cbme' must already exist.
Unprotected code cannot READ if 'cb' or 'cbme' is protected. Unprotected code cannot read a protected instruction.
RETURNS: On success, the length of the code block read is returned. On failure, a negative error code is returned. ENERGY: READ MODE BITS: write an entire code block to another cell or spore Write code block 'cbme' to another cell or spore. The cell is located at the normalized (x, y) offset from
this cell. The destination code block number is given by 'cb'. It is not possible to grow the number of
code blocks of a program. The destination code block 'cb' must already exist.
Unprotected code cannot WRITE if 'cb' or 'cbme' is protected. Unprotected code cannot write a protected instruction.
RETURNS: On success, the length of the code block written is returned. On failure, a negative error code is returned. ENERGY: WRITE MODE BITS: get energy of organism Get our organisms overall energy. RETURNS: ENERGY: return age of organism Fetch the organisms "age" field (which is the number of elapsed simulation step) and push this value on our data
stack. RETURNS:
The age of the organism
ENERGY: Does not use energy. number of cells Push the number of cells that comprise this organism on our data stack. RETURNS:
number of cells in this organism
ENERGY: Does not use energy. check for our cells Determine if a neighboring cell location contains our cell or not. RETURNS: ENERGY: Does not use energy. Returns a bitmask with a '1' bit set for a neighor in that direction. RETURNS: A bit mask representing the surrounding neighbors. ENERGY: get current position Returns the absolute grid coordinates for the cell executing this instruction. RETURNS: ENERGY: get universe-wide global variable Get universe-wide global variable. This is a common global that all CELL's can query with this instruction. RETURNS: ENERGY: set universe-wide global variable Set universe-wide global variable. This is a common global that all CELL's can write to with this instruction. RETURNS: ENERGY: get strain-wide global variable Get strain-wide global variable. Each strain has its own S0 global variable. This instruction allows the strain specific variable to
be queried.
This variable can be used by a swarm of organisms, from the same strain, to coordinate their activies.
RETURNS: ENERGY: set strain-wide global variable Set strain-wide global variable. Each strain has its own S0 global variable. This instruction allows the strain specific variable to
be written to.
This variable can be used by a swarm of organisms, from the same strain, to coordinate their activies.
RETURNS: ENERGY: total population Return the current population. RETURNS: The total population of the universe. This is the total number or organisms. ENERGY: strain population Return the current population of my strain. RETURNS: The population (number of organisms) for my strain. ENERGY: read keyboard Get the keyboard character being pressed. Or 0 if nothing is being pressed. RETURNS: Returns the ascii character code. Returns 0 if no key is pressed. ENERGY: KEY-PRESS MODE BITS: get mouse position Query the mouse position. The mouse position is a coordinate in the universe coordinate space. This position was set externally
by the user right clicking on a grid location when in 'MOUSE-POS' mode. See the KEY-PRESS instruction modes to configure
interrupts for the mouse position. RETURNS: Returns a coordinate in the universe which was set by the user clicking in the grid when in MOUSE-POS mode.
Returns (-1,-1) if no position set. ENERGY: compute vector distance Computes the maximum of ABS(x) and ABS(y). RETURNS: ENERGY:OMOVE
Usage: ( x y -- n )
BIT MASK Meaning when bit is 0 Meaning when bit is 1 0 1 NOT USED NOT USED ROTATE
Usage: ( n -- r )
BIT MASK Meaning when bit is 0 Meaning when bit is 1 0 1 use my location as the origin of rotation use the organism center as the origin of rotation 1 2 rotate in 45 degree units rotate in 90 degree units EAT
Usage: ( x y -- n )
BIT MASK Meaning when bit is 0 Meaning when bit is 1 0 1 I cannot eat myself I can eat myself 1 2 I can eat cells from other strains I cannot eat cells from other strains 2 4 I can eat my own strain I cannot eat my own strain 3 8 I can be eaten I cannot be eaten 4 16 energy eaten is: cell energy + remainder (this bit is respected only if bits 5, 6, 7,8 are off) energy eaten is: cell energy 5 32 off use make-spore energy for maximum energy eaten 6 64 off use grow energy for maximum energy eaten 7 128 off use cell energy/2 + remainder 8 256 off use cell energy/3 + remainder 9 512 terminate cell eaten don't terminate cell eaten, unless energy per cell == 0 10 1024 do not interrupt me, when somebody EATS me interrupt me and bit 0 of the trap number shall be 1 11 2048 do not interrupt me, when somebody EATS me interrupt me and bit 1 of the trap number shall be 1 12 4096 do not interrupt me, when somebody EATS me interrupt me and bit 2 of the trap number shall be 1 SEND-ENERGY
Usage: (e x y -- rc)BIT MASK Meaning when bit is 0 Meaning when bit is 1 0 1 i can give energy to other strains i cannot give energy to other strains 1 2 i can take energy from other strains i cannot take energy from other strains 2 4 i can give energy to spores i cannot give energy to spores 3 8 i can take energy from spores i cannot take energy from spores 4 16 do not interrupt me, when somebody gives energy to me interrupt me and bit 0 of the trap number shall be 1 5 32 do not interrupt me, when somebody gives energy to me interrupt me and bit 1 of the trap number shall be 1 6 64 do not interrupt me, when somebody gives energy to me interrupt me and bit 2 of the trap number shall be 1 7 128 do not interrupt me, when somebody takes energy from me interrupt me and bit 0 of the trap number shall be 1 8 256 do not interrupt me, when somebody takes energy from me interrupt me and bit 1 of the trap number shall be 1 9 512 do not interrupt me, when somebody take energy from me interrupt me and bit 2 of the trap number shall be 1 10 1024 can give energy only to adjacent neighbors can give energy across distances along normalized vector MAKE-SPORE
Usage: ( x y e -- r )
BIT MASK Meaning when bit is 0 Meaning when bit is 1 0 1 NOT USED NOT USED 1 2 i can fertilize a spore i created i cannot fertilize a spore i created 2 4 i can fertilize a spore created by others i cannot fertilize a spore created by others 3 8 i can create a spore i cannot create a spore 4 16 i can fertilize a spore i cannot fertilize a spore 5 32 no energy is required to fertilize a spore minimum MAKE-SPORE Energy is required to fertilize a spore GROW
Usage: ( x y -- r )
BIT MASK Meaning when bit is 0 Meaning when bit is 1 0 1 NOT USED NOT USED MAKE-ORGANIC
Usage: (x y e -- s)
BIT MASK Meaning when bit is 0 Meaning when bit is 1 0 1 NOT USED NOT USED GROW.CB
Usage: (x y cb -- r)
CSHIFT
Usage: (x y -- r)BIT MASK Meaning when bit is 0 Meaning when bit is 1 0 1 NOT USED NOT USED SPAWN
Usage: (x y e strain cb -- r)BIT MASK Meaning when bit is 0 Meaning when bit is 1 0 1 do not inherit cell register values inherit register values 1 2 num. protected code blocks follows new strain num. protected code blocks follows old strain 2 4 cannot spawn to a different strain can spawn to a different strain 3 8 mutate the program using my strain's mutations settings do not mutate the program 4 16 do not inherit data stack inherit N data stack items from top and bit-0 of N is 1 5 32 do not inherit data stack inherit N data stack items from top and bit-1 of N is 1 6 64 do not inherit data stack inherit N data stack items from top and bit-2 of N is 1 MAKE-BARRIER
Usage: (x y -- r)
BIT MASK Meaning when bit is 0 Meaning when bit is 1 0 1 allowed to create a barrier not allowed to create a barrier 1 2 allowed to clear a barrier not allowed to clear a barrier EXUDE
Usage: (value x y -- )BIT MASK Meaning when bit is 0 Meaning when bit is 1 0 1 i can exude on any surrounding square i cannot exude on any surrounding square, if it's occupied by anything 1 2 i can exude on any surrounding square i cannot exude on any surrounding square, if it's occupied by barrier 2 4 i can exude on any surrounding square, if it's occupied by cells from another organism i cannot exude on any surrounding square, if it's occupied by cell from another organism 3 8 i can exude on any surrounding square, if it's occupied by cell from another strain i cannot exude on any surrounding square, if it's occupied by cell from another strain 4 16 i can exude on a spore i cannot exude on a spore 5 32 i can exude on an organic block i cannot exude an an organic block SMELL
Usage: (x y -- value)LOOK
Usage: ( x y -- what dist )
BIT MASK Meaning when bit is 0 Meaning when bit is 1 0 1 when looking along a line any cells that belong to my organism are ignored when looking along a line any cells that belong to my organism stop the looking and report nothing 1 2 NOT USED NOT USED 2 4 when reporting a 'what' bit mask, don't include strain bits when reporting a 'what' bit mask, include strain bits 3 8 i am not invisible i am invisible NEAREST
Usage: ( mask -- x y )
FARTHEST
Usage: ( mask -- x y )
SIZE
Usage: (x y -- size dist)BIGGEST
Usage: (mask -- x y)
SMALLEST
Usage: (mask -- x y)
TEMPERATURE
Usage: (x y -- energy dist)
HOTTEST
Usage: (mask -- x y)
COLDEST
Usage: (mask -- x y)
MOOD
Usage: ( x y -- m )
0 0 MOOD ; returns -23
-1 0 MOOD ; returns 123
-1 1 MOOD ; returns 33
99 99 MOOD ; returns 0
MOOD!
Usage: ( m -- )
0 0 MOOD 1 + MOOD!
BROADCAST
Usage: ( m -- )BIT MASK Meaning when bit is 0 Meaning when bit is 1 0 1 do not interrupt me, when somebody broadcasts a message to me interrupt me and bit 0 of the trap number shall be 1 1 2 do not interrupt me, when somebody broadcasts a message to me interrupt me and bit 1 of the trap number shall be 1 2 4 do not interrupt me, when somebody broadcasts a message to me interrupt me and bit 2 of the trap number shall be 1 SEND
Usage: ( m x y -- )
100 1 0 SEND ; set cell 2's message register to 100
-46812 0 1 SEND ; set cell 3's message register to -46812
0 0 0 SEND ; set out message register to 0.
12 -99 99 SEND ; does nothing because (-99, 99) is bogus
BIT MASK Meaning when bit is 0 Meaning when bit is 1 0 1 do not interrupt me, when somebody sends a message to me interrupt me and bit 0 of the trap number shall be 1 1 2 do not interrupt me, when somebody sends a message to me interrupt me and bit 1 of the trap number shall be 1 2 4 do not interrupt me, when somebody sends a message to me interrupt me and bit 2 of the trap number shall be 1 RECV
Usage: ( -- m )SHOUT
Usage: (m -- r)BIT MASK Meaning when bit is 0 Meaning when bit is 1 0 1 i can shout thru myself i cannot shout thru myself 1 2 i can shout at cells that belong to my strain i cannot shout at cells that belong to my strain 2 4 i can shout at cells that belong to OTHER strains i cannot shout at cells that belong to OTHER strains 3 8 other strains can shout at me other strains cannot shout at me 4 16 do not interrupt me, when somebody shouts a message to me interrupt me and bit 0 of the trap number shall be 1 5 32 do not interrupt me, when somebody shouts a message to me interrupt me and bit 1 of the trap number shall be 1 6 64 do not interrupt me, when somebody shouts a message to me interrupt me and bit 2 of the trap number shall be 1 SAY
Usage: (m x y -- dist)BIT MASK Meaning when bit is 0 Meaning when bit is 1 0 1 i can speak thru myself i cannot speak thru myself 1 2 i can speak at cell that belong to my organism i cannot speak at cell that belong to my organism 2 4 i can speak at cells that belong to my strain i cannot speak at cells that belong to my strain 3 8 i can speak at cell that belong to OTHER strains i cannot speak at cell that belong to OTHER strains 4 16 other strains can speak at me other strains cannot speak at me 5 32 do not interrupt me, when somebody speaks a message to me interrupt me and bit 0 of the trap number shall be 1 6 64 do not interrupt me, when somebody speaks a message to me interrupt me and bit 1 of the trap number shall be 1 7 128 do not interrupt me, when somebody speaks a message to me interrupt me and bit 2 of the trap number shall be 1 LISTEN
Usage: (x y -- mood dist)BIT MASK Meaning when bit is 0 Meaning when bit is 1 0 1 when listening along a line any cells that belong to my organism are ignored when listening along a line any cells that belong to my organism stop the listing process and report nothing READ
Usage: (x y cb cbme -- rc)
BIT MASK Meaning when bit is 0 Meaning when bit is 1 0 1 i cannot read from myself i can read from myself 1 2 i can read from cells/spores that belong to my strain i cannot read from cells/spores that belong to my strain 2 4 i cannot read from cells/spores that belong to OTHER strains i can read from cells/spores that belong to OTHER strains 3 8 i can read from spores i cannot read from spores 4 16 i can read from cells i cannot read from cells 5 32 other strains can read from me other strains cannot read from me 6 64 mutate the code block being read with my strain's mutation settings. do not mutate the code block being read WRITE
Usage: (x y cb cbme -- rc)
BIT MASK Meaning when bit is 0 Meaning when bit is 1 0 1 i cannot write to myself i can write to myself 1 2 i can write to cells/spores that belong to my strain i cannot write to cells/spores that belong to my strain 2 4 i cannot write to cells/spores that belong to OTHER strains i can write to cells/spores that belong to OTHER strains 3 8 i can write to spores i cannot write to spores 4 16 i cannot write to cells i can write to cells 5 32 other strains can write to me other strains cannot write to at me 6 64 mutate the code block being written with my strain's mutation settings. do not mutate the code block being written 7 128 do not interrupt me, when somebody writes to me interrupt me and bit 0 of the trap number shall be 1 8 256 do not interrupt me, when somebody writes to me interrupt me and bit 1 of the trap number shall be 1 9 512 do not interrupt me, when somebody writes to me interrupt me and bit 2 of the trap number shall be 1 ENERGY
Usage: ( -- e )AGE
Usage: ( -- a )NUM-CELLS
Usage: ( -- n )HAS-NEIGHBOR
Usage: ( x y -- r )
NEIGHBORS
Usage: ( -- mask)
GPS
Usage: ( -- x y)G0
Usage: ( -- value)G0!
Usage: (value -- )S0
Usage: ( -- value)S0!
Usage: (value -- )POPULATION
Usage: ( -- pop)POPULATION.S
Usage: ( -- pop)KEY-PRESS
Usage: ( -- key)BIT MASK Meaning when bit is 0 Meaning when bit is 1 0 1 do not interrupt me, when KEY-PRESS changes interrupt me on KEY-PRESS change, and bit 0 of the trap number shall be 1 1 2 do not interrupt me, when KEY-PRESS changes interrupt me on KEY-PRESS change, and bit 1 of the trap number shall be 1 2 4 do not interrupt me, when KEY-PRESS changes interrupt me on KEY-PRESS change, and bit 2 of the trap number shall be 1 3 8 do not interrupt me, when MOUSE-POS changes interrupt me on MOUSE-POS change, and bit 0 of the trap number shall be 1 4 16 do not interrupt me, when MOUSE-POS changes interrupt me on MOUSE-POS change, and bit 1 of the trap number shall be 1 5 32 do not interrupt me, when MOUSE-POS changes interrupt me on MOUSE-POS change, and bit 2 of the trap number shall be 1 MOUSE-POS
Usage: ( -- x y)DIST
Usage: (x y -- dist)