Last updated: January 16th, 2023
Evolve 5.0
VOLVE    5.0

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:

INSTRUCTIONUSAGEDESCRIPTION
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:

INSTRUCTIONUSAGEDESCRIPTION
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.

  • 1 = Cell
  • 2 = Spore
  • 4 = Organic Material
  • 8 = Barrier
  • 16 = Self
  • 32 = Strain 0
  • 64 = Strain 1
  • 128 = Strain 2
  • 256 = Strain 3
  • 512 = Strain 4
  • 1024 = Strain 5
  • 2048 = Strain 6
  • 4096 = Strain 7

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.

  • 1 = Cell
  • 2 = Spore
  • 4 = Organic Material
  • 8 = Barrier
  • 16 = Self
  • 32 = Strain 0
  • 64 = Strain 1
  • 128 = Strain 2
  • 256 = Strain 3
  • 512 = Strain 4
  • 1024 = Strain 5
  • 2048 = Strain 6
  • 4096 = Strain 7

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.

  • 1 = Cell
  • 2 = Spore
  • 4 = Organic Material
  • 8 = Barrier
  • 16 = Self
  • 32 = Strain 0
  • 64 = Strain 1
  • 128 = Strain 2
  • 256 = Strain 3
  • 512 = Strain 4
  • 1024 = Strain 5
  • 2048 = Strain 6
  • 4096 = Strain 7

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.

  • 1 = Cell
  • 2 = Spore
  • 4 = Organic Material
  • 8 = Barrier
  • 16 = Self
  • 32 = Strain 0
  • 64 = Strain 1
  • 128 = Strain 2
  • 256 = Strain 3
  • 512 = Strain 4
  • 1024 = Strain 5
  • 2048 = Strain 6
  • 4096 = Strain 7

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.

  • 1 = Cell
  • 2 = Spore
  • 4 = Organic Material
  • 8 = Barrier
  • 16 = Self
  • 32 = Strain 0
  • 64 = Strain 1
  • 128 = Strain 2
  • 256 = Strain 3
  • 512 = Strain 4
  • 1024 = Strain 5
  • 2048 = Strain 6
  • 4096 = Strain 7

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.

  • 1 = Cell
  • 2 = Spore
  • 4 = Organic Material
  • 8 = Barrier
  • 16 = Self
  • 32 = Strain 0
  • 64 = Strain 1
  • 128 = Strain 2
  • 256 = Strain 3
  • 512 = Strain 4
  • 1024 = Strain 5
  • 2048 = Strain 6
  • 4096 = Strain 7

This instruction also uses the LOOK Mode bits.



Communicating between cells:

INSTRUCTIONUSAGEDESCRIPTION
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:

INSTRUCTIONUSAGEDESCRIPTION
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:

INSTRUCTIONUSAGEDESCRIPTION
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:

INSTRUCTIONUSAGEDESCRIPTION
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.

  1. If there are not 2 elements on the data stack, then skip this instruction.
  2. Remove the (x, y) coordinates from the stack.
  3. Normalize the coordinates.
  4. Examine the destination square (as indicated by the offsets) and see if it is vacant. If not, return 0.
  5. Check that the organism is propery connected after the move. If not return 0.
  6. Else, Move the cell to the new location and return 1.
  7. A CMOVE of (0,0) always fails and returns 0.

RETURNS:

ENERGY: Does not require any energy.

CMOVE MODE BITS:

BITMASKMeaning when bit is 0Meaning when bit is 1
01 NOT USED

NOT USED


OMOVE

Usage: ( x y -- n )

move entire organism

Move entire organism by one square in the up, down, left, right, or diagonal direction.

  1. If there are not 2 elements on the data stack, then skip this instruction.
  2. Remove the (x, y) coordinates from the stack.
  3. Normalize the coordinates.
  4. Examine every square that we may be moving to to make sure it is empty, or contains one of our cells.
  5. If the move is possible, reposition every cell in our organism by the (x, y) offset.
  6. A move using vector (0, 0) always fails, and returns 0.

RETURNS:

ENERGY: Does not require any energy.

OMOVE MODE BITS:

BITMASKMeaning when bit is 0Meaning when bit is 1
01 NOT USED

NOT USED


ROTATE

Usage: ( n -- r )

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.

  1. If there is not 1 element on the data stack, then skip this instruction.
  2. Remove the rotation amount n from the stack.
  3. Translate all cells in the organism to the new location, and check that the spot is vacant (or contains cells from this organism). If not, return 0.
  4. Else, rotate organism and return 1.
  5. A rotation value of 0 does nothing, and returns 0.

RETURNS:

ENERGY: Does not require any energy.

ROTATE MODE BITS:

BITMASKMeaning when bit is 0Meaning when bit is 1
01 use my location as the origin of rotation

use the organism center as the origin of rotation

12 rotate in 45 degree units

rotate in 90 degree units


EAT

Usage: ( x y -- n )

eat energy from surrounding cells

Eat stuff at (x, y) from this cell. Return 'n' the amount of energy eaten.

  1. Normalize the (x, y) coordinates.
  2. Try to eat whatever is at this location:
  3. Organic material (white squares) will be eaten and all its energy transferred to this organism.
  4. Spores (blue squares) will be eaten and all their energy transferred to this organism. Even spores created by this organism will be eaten (so be careful!).
  5. Depending on the modes, living tissue from other creatures will be eaten like this:

RETURNS:

ENERGY: Does not require any energy.

EAT MODE BITS:

BITMASKMeaning when bit is 0Meaning when bit is 1
01 I cannot eat myself

I can eat myself

12 I can eat cells from other strains

I cannot eat cells from other strains

24 I can eat my own strain

I cannot eat my own strain

38 I can be eaten

I cannot be eaten

416 energy eaten is: cell energy + remainder (this bit is respected only if bits 5, 6, 7,8 are off)

energy eaten is: cell energy

532 off

use make-spore energy for maximum energy eaten

664 off

use grow energy for maximum energy eaten

7128 off

use cell energy/2 + remainder

8256 off

use cell energy/3 + remainder

9512 terminate cell eaten

don't terminate cell eaten, unless energy per cell == 0

101024 do not interrupt me, when somebody EATS me

interrupt me and bit 0 of the trap number shall be 1

112048 do not interrupt me, when somebody EATS me

interrupt me and bit 1 of the trap number shall be 1

124096 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)

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:

BITMASKMeaning when bit is 0Meaning when bit is 1
01 i can give energy to other strains

i cannot give energy to other strains

12 i can take energy from other strains

i cannot take energy from other strains

24 i can give energy to spores

i cannot give energy to spores

38 i can take energy from spores

i cannot take energy from spores

416 do not interrupt me, when somebody gives energy to me

interrupt me and bit 0 of the trap number shall be 1

532 do not interrupt me, when somebody gives energy to me

interrupt me and bit 1 of the trap number shall be 1

664 do not interrupt me, when somebody gives energy to me

interrupt me and bit 2 of the trap number shall be 1

7128 do not interrupt me, when somebody takes energy from me

interrupt me and bit 0 of the trap number shall be 1

8256 do not interrupt me, when somebody takes energy from me

interrupt me and bit 1 of the trap number shall be 1

9512 do not interrupt me, when somebody take energy from me

interrupt me and bit 2 of the trap number shall be 1

101024 can give energy only to adjacent neighbors

can give energy across distances along normalized vector


MAKE-SPORE

Usage: ( x y e -- r )

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.

  1. If there are not 3 elements on the data stack, then skip this instruction.
  2. Remove energy 'e' from the stack. (this is the amount of energy that this organism will give up and transfer to the new spore).
  3. Remove the (x, y) coordinates from the stack.
  4. Normalize the coordinates.
  5. For new spores, if energy 'e' is less than or equal to 0, then return 0.
  6. For fertilizing an existing spore, if energy 'e' is less than 0, then return 0.
  7. If energy 'e' is more than the amount of energy this organism has, then return 0.
  8. If the location indicated by the normalized (x, y) coordinates is not vacant or is not a spore, then return 0.
  9. If the location is blank, then create the first spore. Transfer 'e' units of energy from this organism and give it to the new spore. Return 1.
  10. If the location is a spore then fertilize the existing spore. Transfer 'e' units of energy from this organism to the fertilized spore. Return -1.

RETURNS:

ENERGY: Requires 'e' units of energy.

MAKE-SPORE MODE BITS:

BITMASKMeaning when bit is 0Meaning when bit is 1
01 NOT USED

NOT USED

12 i can fertilize a spore i created

i cannot fertilize a spore i created

24 i can fertilize a spore created by others

i cannot fertilize a spore created by others

38 i can create a spore

i cannot create a spore

416 i can fertilize a spore

i cannot fertilize a spore

532 no energy is required to fertilize a spore

minimum MAKE-SPORE Energy is required to fertilize a spore


GROW

Usage: ( x y -- r )

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.

  1. If there are not 2 elements on the data stack, then skip this instruction.
  2. Remove the (x, y) coordinates from the stack.
  3. Normalize the coordinates.
  4. If the location specified by the coordinates is not blank, then return 0.
  5. Compute the amount of energy needed to grow (this is the sum of the data stack size and the call stack size).
  6. If organims does not have enough energy to GROW a new cell, then return 0.
  7. Create new cell at location specified. Clone this cells data and call stack (as well as registers, and so on).
  8. For the cell executing the GROW instruction return 1.
  9. For the new cell, just created, make it appear as if it returned -1.

RETURNS:

ENERGY: Requires GROW Energy units of energy.

GROW MODE BITS:

BITMASKMeaning when bit is 0Meaning when bit is 1
01 NOT USED

NOT USED


MAKE-ORGANIC

Usage: (x y e -- s)

create organic block

Create organic block at (x,y) offset with energy e.

  1. Normalize the (x, y) ccoordinated, if the offset if not vacant return s=0.
  2. If organism doesn't have enough energy return s=0.
  3. If organic already exists, append 'e' energy to it and return s=e
  4. If blank exists then create new organic block with energy 'e'. return s=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:

BITMASKMeaning when bit is 0Meaning when bit is 1
01 NOT USED

NOT USED


GROW.CB

Usage: (x y cb -- r)

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.


CSHIFT

Usage: (x y -- r)

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:

BITMASKMeaning when bit is 0Meaning when bit is 1
01 NOT USED

NOT USED


SPAWN

Usage: (x y e strain cb -- r)

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:

BITMASKMeaning when bit is 0Meaning when bit is 1
01 do not inherit cell register values

inherit register values

12 num. protected code blocks follows new strain

num. protected code blocks follows old strain

24 cannot spawn to a different strain

can spawn to a different strain

38 mutate the program using my strain's mutations settings

do not mutate the program

416 do not inherit data stack

inherit N data stack items from top and bit-0 of N is 1

532 do not inherit data stack

inherit N data stack items from top and bit-1 of N is 1

664 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)

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:

BITMASKMeaning when bit is 0Meaning when bit is 1
01 allowed to create a barrier

not allowed to create a barrier

12 allowed to clear a barrier

not allowed to clear a barrier


EXUDE

Usage: (value x y -- )

excrete a value onto the grid

excrete a value onto the grid

RETURNS:

ENERGY:

EXUDE MODE BITS:

BITMASKMeaning when bit is 0Meaning when bit is 1
01 i can exude on any surrounding square

i cannot exude on any surrounding square, if it's occupied by anything

12 i can exude on any surrounding square

i cannot exude on any surrounding square, if it's occupied by barrier

24 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

38 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

416 i can exude on a spore

i cannot exude on a spore

532 i can exude on an organic block

i cannot exude an an organic block


SMELL

Usage: (x y -- value)

read a value from the grid

read a value from the grid that was previously EXUDE'd.

RETURNS:

ENERGY:


LOOK

Usage: ( x y -- what dist )

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.

  1. If there are not 2 elements on the data stack, then skip this instruction.
  2. Remove the (x, y) coordinates from the stack and normalize the coordinate.
  3. Look along the direction vector until something is found (or the edge of the universe is reached).
  4. Ignore any cell that happens to be from the same organism as us.
  5. Push the type of thing ('what' value) on the data stack. (WHAT value Key: 1=cell, 2=spore, 4=organic material, 8=barrier).
  6. Push the distance ('dist' value) on the data stack. A distance of 1 means the thing seen is touching this cell.

RETURNS:

What values:

ENERGY: Does not use energy.

LOOK MODE BITS:

BITMASKMeaning when bit is 0Meaning when bit is 1
01 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

12 NOT USED

NOT USED

24 when reporting a 'what' bit mask, don't include strain bits

when reporting a 'what' bit mask, include strain bits

38 i am not invisible

i am invisible


NEAREST

Usage: ( mask -- x y )

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.

  1. If there is not 1 element on the data stack, then skip this instruction.
  2. remove 'mask' value from data stack.
  3. strip all bits from the mask, except first 4 bits (e.g. 000001111)
  4. if mask bits are all 0, then return the vector (0, 0)
  5. Look in all 8 directions, beginning with a RANDOM direction and proceeding in a clock-wise direction.
  6. Keep track of the closest thing seen (whose 'what' value is set in the bit-mask)
  7. Return the (x, y) direction vector.
  8. If nothing matched the bit-mask, then (0, 0) is returned.

RETURNS:

ENERGY: Does not use energy.


FARTHEST

Usage: ( mask -- x y )

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.

  1. If there is not 1 element on the data stack, then skip this instruction.
  2. remove 'mask' value from data stack.
  3. strip all bits from the mask, except first 4 bits (e.g. 000001111)
  4. if mask bits are all 0, then return the vector (0, 0)
  5. Look in all 8 directions, beginning with a RANDOM direction and proceeding in a clock-wise direction.
  6. Keep track of the farthest thing seen (whose 'what' value is set in the bit-mask)
  7. Return the (x, y) direction vector.
  8. If nothing matched the bit-mask, then (0, 0) is returned.

RETURNS:

ENERGY: Does not use energy.


SIZE

Usage: (x y -- size dist)

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:


BIGGEST

Usage: (mask -- x y)

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:


SMALLEST

Usage: (mask -- x y)

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:


TEMPERATURE

Usage: (x y -- energy dist)

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:


HOTTEST

Usage: (mask -- x y)

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:


COLDEST

Usage: (mask -- x y)

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:


MOOD

Usage: ( x y -- m )

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:

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).

RETURNS:

ENERGY: Does not use energy.


MOOD!

Usage: ( m -- )

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:

0 0 MOOD 1 + MOOD!

Then cell 3's mood would be increased by 1. So it would be set to 34.

RETURNS:

ENERGY: Does not use energy.


BROADCAST

Usage: ( m -- )

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:

BITMASKMeaning when bit is 0Meaning when bit is 1
01 do not interrupt me, when somebody broadcasts a message to me

interrupt me and bit 0 of the trap number shall be 1

12 do not interrupt me, when somebody broadcasts a message to me

interrupt me and bit 1 of the trap number shall be 1

24 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 -- )

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:

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.

RETURNS:

ENERGY: Does not use energy.

SEND MODE BITS:

BITMASKMeaning when bit is 0Meaning when bit is 1
01 do not interrupt me, when somebody sends a message to me

interrupt me and bit 0 of the trap number shall be 1

12 do not interrupt me, when somebody sends a message to me

interrupt me and bit 1 of the trap number shall be 1

24 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 )

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.


SHOUT

Usage: (m -- r)

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:

BITMASKMeaning when bit is 0Meaning when bit is 1
01 i can shout thru myself

i cannot shout thru myself

12 i can shout at cells that belong to my strain

i cannot shout at cells that belong to my strain

24 i can shout at cells that belong to OTHER strains

i cannot shout at cells that belong to OTHER strains

38 other strains can shout at me

other strains cannot shout at me

416 do not interrupt me, when somebody shouts a message to me

interrupt me and bit 0 of the trap number shall be 1

532 do not interrupt me, when somebody shouts a message to me

interrupt me and bit 1 of the trap number shall be 1

664 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)

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:

BITMASKMeaning when bit is 0Meaning when bit is 1
01 i can speak thru myself

i cannot speak thru myself

12 i can speak at cell that belong to my organism

i cannot speak at cell that belong to my organism

24 i can speak at cells that belong to my strain

i cannot speak at cells that belong to my strain

38 i can speak at cell that belong to OTHER strains

i cannot speak at cell that belong to OTHER strains

416 other strains can speak at me

other strains cannot speak at me

532 do not interrupt me, when somebody speaks a message to me

interrupt me and bit 0 of the trap number shall be 1

664 do not interrupt me, when somebody speaks a message to me

interrupt me and bit 1 of the trap number shall be 1

7128 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)

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:

BITMASKMeaning when bit is 0Meaning when bit is 1
01 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)

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:

BITMASKMeaning when bit is 0Meaning when bit is 1
01 i cannot read from myself

i can read from myself

12 i can read from cells/spores that belong to my strain

i cannot read from cells/spores that belong to my strain

24 i cannot read from cells/spores that belong to OTHER strains

i can read from cells/spores that belong to OTHER strains

38 i can read from spores

i cannot read from spores

416 i can read from cells

i cannot read from cells

532 other strains can read from me

other strains cannot read from me

664 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)

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:

BITMASKMeaning when bit is 0Meaning when bit is 1
01 i cannot write to myself

i can write to myself

12 i can write to cells/spores that belong to my strain

i cannot write to cells/spores that belong to my strain

24 i cannot write to cells/spores that belong to OTHER strains

i can write to cells/spores that belong to OTHER strains

38 i can write to spores

i cannot write to spores

416 i cannot write to cells

i can write to cells

532 other strains can write to me

other strains cannot write to at me

664 mutate the code block being written with my strain's mutation settings.

do not mutate the code block being written

7128 do not interrupt me, when somebody writes to me

interrupt me and bit 0 of the trap number shall be 1

8256 do not interrupt me, when somebody writes to me

interrupt me and bit 1 of the trap number shall be 1

9512 do not interrupt me, when somebody writes to me

interrupt me and bit 2 of the trap number shall be 1


ENERGY

Usage: ( -- e )

get energy of organism

Get our organisms overall energy.

RETURNS:

ENERGY:


AGE

Usage: ( -- a )

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.


NUM-CELLS

Usage: ( -- n )

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.


HAS-NEIGHBOR

Usage: ( x y -- r )

check for our cells

Determine if a neighboring cell location contains our cell or not.

  1. On the data stack should be two values. If not, we ignore this instruction.
  2. The two values are popped off the stack (they are NOT normalized). This forms an (x, y) vector that refers to one of our nearby grid locations.
  3. If we have a cell at this (x, y) offset, then this instruction returns 1. Else 0 will be returned.
  4. The vector (0,0) is allowed, and always returns 1.

RETURNS:

ENERGY: Does not use energy.


NEIGHBORS

Usage: ( -- mask)

Returns a bitmask with a '1' bit set for a neighor in that direction.

RETURNS: A bit mask representing the surrounding neighbors.

ENERGY:


GPS

Usage: ( -- x y)

get current position

Returns the absolute grid coordinates for the cell executing this instruction.

RETURNS:

ENERGY:


G0

Usage: ( -- value)

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:


G0!

Usage: (value -- )

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:


S0

Usage: ( -- value)

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:


S0!

Usage: (value -- )

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:


POPULATION

Usage: ( -- pop)

total population

Return the current population.

RETURNS: The total population of the universe. This is the total number or organisms.

ENERGY:


POPULATION.S

Usage: ( -- pop)

strain population

Return the current population of my strain.

RETURNS: The population (number of organisms) for my strain.

ENERGY:


KEY-PRESS

Usage: ( -- key)

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:

BITMASKMeaning when bit is 0Meaning when bit is 1
01 do not interrupt me, when KEY-PRESS changes

interrupt me on KEY-PRESS change, and bit 0 of the trap number shall be 1

12 do not interrupt me, when KEY-PRESS changes

interrupt me on KEY-PRESS change, and bit 1 of the trap number shall be 1

24 do not interrupt me, when KEY-PRESS changes

interrupt me on KEY-PRESS change, and bit 2 of the trap number shall be 1

38 do not interrupt me, when MOUSE-POS changes

interrupt me on MOUSE-POS change, and bit 0 of the trap number shall be 1

416 do not interrupt me, when MOUSE-POS changes

interrupt me on MOUSE-POS change, and bit 1 of the trap number shall be 1

532 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)

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:


DIST

Usage: (x y -- dist)

compute vector distance

Computes the maximum of ABS(x) and ABS(y).

RETURNS:

ENERGY:


CHOOSE

Usage: (min max -- rnd)

pick random value between two values

pick random value between two values

RETURNS:

ENERGY:


RND

Usage: ( -- rnd)

return random value between MIN_INT and MAX_INT

return random value between MIN_INT and MAX_INT.

RETURNS:

ENERGY: