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

Organisms and Cells

This page will discusss the mechanics of how cells and organisms interact with the universe.

Theory of Operation

CELLs are CPUs that have a small repertoire of instructions for manipulating the world. All of the physics of the simulation are embodied by these instructions. The general physics to be maintained are: (1) Locality (most instructions operate on nearest neighbors). (2) Conservation of energy (energy is only ever transferred). (3) Exclusion principle (nothing can occupy the same grid location as something else). (4) Connectivity of the cells in an organism.

These instructions can all be independenly enabled/disabled in your simulation. Each instruction can be tweaked and modified using mode flags.

These instructions need a programmatic way to specify what they want to happen. The most important detail is specifying (x,y) coordinates for the instruction. So coordinates will be discussed next.

Table of Contents:


Coordinate System

The grid uses the following (x,y) coordinate system:



Here's a simulation screen showing the origin in the lower left.


Directions

Many of the instructions that cells execute require a vector. This vector is used to indicate a direction, or an adjacent square that the organism or cell will interact with. This diagram shows (x, y) coordinates for the eight directions surrounding a cell:

Most operations that interact with the universe using (x, y) coordinates will specify coordinates like these. This is called a normalized direction vector.

Not shown is the direction (0, 0) which correponds to the cell in the middle. This is normally the cell executing the instruction.

Some instructions use non-normalized direction vectors, such as MOOD and SEND. In this case any values may be given for (x, y) such as (-4, 2).


Normalized Vectors

Because most operations are restricted to the adjacent squares, (x,y) vectors will often be normalized before using them. Here is how Evolve instructions normalize coordinates to values of -1, 0, +1.

For example,

-30  4   OMOVE		; move organism using vector (-1, 1)
  0 -4   CMOVE		; move cell using vector (0, -1)
  9 29 5 MAKE-SPORE	; make spore using vector (1, 1) (with energy 5)

Organism Connectivity

Organisms consists of one or more cells. To ensure the shape of an organism remains coherent Evolve will enforce the connectivity constraint that a cell much be reachable in one of the 8 directions surrounding the cell.

Here are examples of organisms:

One of its corner cells has been killed,

Our connectivity constraints are such that a multi-cellular organism must always have at least one neighbor in one of the 8 directions.

In this example, after the dead cell is removed, we still have a properly connected organism.

Sometimes the connectivity between the cells is broken. If a cell is kills, the largest region is kept, and the smaller regions will be converted to organic material.

In this case the death of this cell does not break the organism into multiple sections. So in this case we just kill of the cell in question.

These are properly connected:

This is because all the cells are touching in at least one of the 8 directions.


Energy

Energy is an attribute of each organism. The total amount of energy in a simulation is equal to the amount of energy that the first organism(s) had when the simulation was created. The total energy never changes during a simulation (conservation of energy).

Every cell must have at least one unit of energy just to be considered "alive". If some operation causes this value to go to zero, the cell is dead.

Why Energy?

The purpose of energy is to introduce a limit on organism/cell growth. Without it, organisms would replicate without limit. Other constrains may be introduced that changes how energy is used to limit growth.

Energy and Organic Material

When a cell is killed by being eaten, the connectivity algorithm must analyse the organism and kill of all but the largest region. Each cell in a region that is killed off will be converted to organic material. The amount of energy that this organic material will contain is equal to 1/n th the amount of energy in the organism (where n is the number of cells in the organism) plus any stack elements beyond 10.

Energy and Spores

A spore gets created with an energy amount (specified by the MAKE-SPORE instruction). If a spore gets eaten then this energy amount is transferred to the organism that ate it. If a spore is fertilized, then the new organism gets created with the sum of energy from the first and second MAKE-SPORE instructions.

Energy and Other Operations

Energy is not needed to move, look, eat, etc.... Energy is only needed to Grow, Make a spore, Reproduce.

Use energy to control the overall population of your simulation:

Other things will determine the population you will see. Energy Requirements are configurable on the Modes tab.


OMOVE

The OMOVE instruction causes the entire organism to move in one of the 8 directions.

Assume that cell 2 has executed the instruction 1 0 OMOVE. The vector (1,0) means move right 1 square.

Or assume that cell 1 has executed the instruction -1 -1 OMOVE. The vector (-1, -1) means move left and down diagonally.

The OMOVE instruction first checks that all squares that organism will move to, are vacant. Note that any cell could have executed these instructions and the organism would have moved the same.


ROTATE

The ROTATE instruction causes the organism to be rotated. Because of the grid layout and the constraints on the shape of organisms, this instruction only rotates in 90 (or 45) degree units. Rotate takes a single integer off of the data stack. This value represents 90 (or 45) degree rotations.

Consider this organism, the cell with the dot will execute a ROTATE instruction. (NOTE: In these examples the ROTATE mode is confugured for 90 degree rotations, and the center of rotation is the cell executing the instruction. These properties can be changed by changing the mode bits.)

Here's what the organism looks like after a -1 ROTATE:

Here's what the organism looks like after a 1 ROTATE (from starting figure):

This instruction requires that all grid locations that the rotated organism is to be moved are vacant.


CMOVE

CMOVE is a cool instruction. It allows a cell to move relative to the organism. The following pictures will demonstrate an organism morphing from one shape to another. The following instructions will be executed:

0 -1 CMOVE	; cell 1 executes this instruction
0 -1 CMOVE	; then cell 4 executes this instruction
1 1 CMOVE	; then cell 5 executes this instruction
0 -1 CMOVE	; <--- cell 1 executes this
0 -1 CMOVE	; <--- cell 4 executes this
1 1 CMOVE	; <--- cell 5 executes this

This last pictures shows what the creature looks like after these 3 CMOVE instructions.

For the the CMOVE operation to succeed the shape being morphed into must always be properly connected.


CSHIFT

The CSHIFT instruction allows the shape of an organism to change by shifting cells along a line. As long as the final shape is properly connected the CSHIFT instruction is allowed. Here is the initial state of some organism. We will see it transform after executing three CSHIFT instructions.

-1 0 CSHIFT   ; <--- cell 5 executes this
-1 0 CSHIFT   ; <--- cell 5 executes this a second time
0 -1 CSHIFT   ; <--- cell 2 executes this

GROW

The GROW instruction is how an organism (which always starts out life as a single cell) becoms multi-cellular.

Let's assume this is our organism:

To get to the state shown below cell 1 executes this:

1 0 GROW ; executed by cell 1

Another GROW operation produces the organism below. What are the possible operations that could create the organism? Here is the only possibility:

1 -1 GROW	; executed by cell 2

As shown above, the GROW operation creates a new cell. The new cell recieves the execution context of the cell that executed the GROW instruction. The only difference is the new cell has a -1 on top of its data stack and the other cell has a 1.

Grow is very much like the fork() system call on Unix. Fork creates a new process. But fork does it by cloning the current process. The only way for a programmer to know which execution context they are in is by examining the return value of fork(). The same applies to the GROW instruction.

Grow also allows a creature to increase its processing power. An organism consisting of two cells has twice the processing power of a single celled creature. Such an organism can do twice the computations in the same amount of steps as a single celled creature. This is profound capability and any creature that makes the leap into multi-cellularism has a lot going for it.

Example KFORTH code using GROW,

main:
{
	1 0 GROW -1 = LeafCell if

	brain call
}

LeafCell:
{
   1 0 EAT pop
   -1 -1 EAT pop
   1 ?loop
}

brain:
{
  ; ... creature brain goes here ...
}

In this example a new cell is grown at coordinates (1, 0), and the new cell begins its life executing inside of the code block 'LeafCell'. The LeafCell just eat's forever. The parent cell continues to call the 'brain' routine to do the normal creature processing.

You can write your routine to encapsulate this common logic as follows:

main:
{
	1 0 LeafCell myGROW call
	brain call
}

LeafCell:
{
    ; .... leaf cell stuff here ...
}

brain:
{
    ; ... brain cell stuff here ...
}

;
; (x y cb -- )
;
; Grow and call 'cb' for the new cell
;
myGROW:
{
	-rot GROW -1 = { pop } ifelse
}

MAKE-SPORE

The MAKE-SPORE instruction is how reproduction occurs. In order to reproduce a spore must be created. But this isn't enough. Another spore must be created on top of the first one.

This mechanism allows both sexual and asexual reproduction. (see spores for more information). The following example shows an organism reproducing asexually:

So our happy organism wants to have a baby. Either cell 2 executes this instruction:

1 0 20 MAKE-SPORE  ; create spore with 20 units of energy

Or cell 3 executes this one:

1 1 20 MAKE-SPORE  ; create spore with 20 units of energy

In either case this is what the universe now looks like:

Now lets assume one of the following instructions gets executed:

1  0 12 MAKE-SPORE  ; cell 2 does this or....
1 -1 12 MAKE-SPORE  ; cell 3 does this

A new organism is born! Whooo hoo. The new organism will start out life with 32 units of energy (20 + 12). The new organism will inherit the genetic program of the parent organism. (with mutations).

Sexual reproduction occurs when two different organisms contribute a spore. In this case the genetic program from both parents is interlaced (this process is described elsewhere).

All organisms belong to a certain strain (by default strain 0). Strains allow you to tag a lineage of organisms from the first one to an evolved population. Therefore, SPORE's cannot be fertilized if the two organisms belong to different strains.

The first MAKE-SPORE operation must have an energy amount that is greather than 0. But the second MAKE-SPORE instruction can fertilize an existing spore using 0 energy.


EAT

Eating is how an organism survives. The EAT instruction must be called to eat stuff that is touching the cell. The cell executing the EAT instruction will attempt to eat anything at the (x, y) offset.

EAT'ing is basically the transfer of energy between cells. Related to this is the SEND-ENERGY instruction. It is like EAT except it allows a precise amount of energy to be transferred. SEND-ENERGY can be used when inventing ones own simulation rules.

In this example cell 2, executes the 1 -1 EAT instruction.

After the instruction the white square (organic material) has been removed.

Not shown is what happens when a cell tries to eat another living cell. In this case the cell being eaten is flagged as dead (it will show up RED). The organism which has dead cells will have to resolve that issue later in the simulation.

The precise rules for EAT and SEND-ENERGY are given by mode flags for EAT and SEND-ENERGY.

To eat the spore located at (0, -1) this instruction could be used: 0 -1 EAT.


LOOK

The LOOK instruction takes a normalized (x, y) vector and looks along that line until it finds something. The thing it finds (the 'what' value) and the distance in which it was found it returned on the data stack.

This figure shows all 8 direction vectors from a single cell. The LOOK instruction would return the following for this cell:

 0  1 LOOK	; what = 8, where = 100
 1  1 LOOK	; what = 2, where = 3
 1  0 LOOK	; what = 1, where = 2
 1 -1 LOOK	; what = 8, where = 4
 0 -1 LOOK	; what = 4, where = 3
-1 -1 LOOK	; what = 8, where = 4
-1  0 LOOK	; what = 2, where = 7
-1  1 LOOK	; what = 4, where = 3

 0  0 LOOK      ; what = 0, where = 0

Vision using LOOK (and the other vision instructions) will look through the organism itself. This makes the vision instructions less evolutionary brittle, as an "eye" cell can evolve inside the middle of a multi-cellular organism.

The 'what' values are powers of 2, which allows them to be OR'd together for form a search mask (see NEAREST and FARTHEST).

A LOOK operation using the vector (0, 0) returns a what=0, where=0.

"What" values are assigned according to this key:

When LOOK is configured to not be able to see through itself, then the additional bit 16 will be set. Also LOOK can be configuired to reveal strain bits. Here is the addtional bits that can be returned by LOOK (and the other vision instructions).


NEAREST

This instruction looks in all 8 directions surrounding a cell and returns the (x, y) vector that has the smallest distance.

This instruction takes a bit-mask which is an OR'ing of 'what' values. Only these types of things will be used when determining the nearest direction.

For example, a mask value of 5 (binary 0101), matches Cells and Organics (but not spores or barriers). So this code,

5 NEAREST	; returns (2, 0)

Would return vector (1, 0) because that direction has a "cell" at distance 2 (which is the smallest distance that matches the bit-mask).

For all vision instructions which take a 'what' mask, the matching criteria works as follows: We AND the two what values together. If non-zero then the object matched. If zero we stop searching along the line and report 0 0. This allows filtering for certain strains as well for certain types of blocks.

NOTE: If more than one direction "tie" for seeing the nearest (or farthest) thing, then instructions NEAREST, FARTHEST, BIGGEST, SMALLEST, HOTTEST, COLDEST will resolve the tie by choosing one of the matches randomly.

NOTE 2: The returned vector from these instructions are not normalized. This means they return the distance as well as the direction. For example (-6, -6) is returned instead of (-1, -1) to indicate both the distance and direction. The DIST instruction can be applied to this vector to get the distance, 6.


FARTHEST

This instruction looks in all 8 directions surrounding a cell and returns the (x, y) vector that has the largest distance.

This instruction takes a bit-mask which is an OR'ing of 'what' values. Only these types of things will be used when determining the farthest direction.

For example, a mask value of 2 (binary 0010), matches only spores (but nothing else). So this code,

2 FARTHEST	; returns (-7, 0)

Would return vector (-7, 0) because that direction has a "spore" at distance 7 (which is the largest distance to any spore).


SMELL

The grid contains an odor value at each (x,y) coordinate. These instructions allow for this 16-bit value to be read/written. The smell instruction lets the cell read a value from the grid.

1 -1 SMELL		; retrieves the value 2 from the grid

EXUDE

The exude instruction allows the cell to write a value to the grid.

1 -1 SMELL		; retrieve the value 2 from the grid
125 -           ; 2 - 125 = -123
-1 0 EXUDE      ; writes the value -123 to the grid

The SMELL and EXUDE instructions use normalized direction vectors to read and write the odor map values from the surrounding 9 squares.


Communicating Between Cells

Cellular Communications

Refer to this figure for the descriptions of the following instructions. The mood register is something the cell sets, and others can look at. The message register is something that others set, and this cell looks at.

SEND

Using the instructions pack2, unpack2 two values can be combined into a single 16-bit integer and stored in the MOOD and MESSAGE registers. For example, to send 2 integers to another cell, this code could be used:

23 -99 pack2        ; combined 2 (8-bit integers) into single 16-bit int.
-1 1 SEND           ; send to cell

RECV

The recieving cell can extract the 2 values like so:

RECV
unpack2         ; the values 23, -99 are now on the stack

BROADCAST

This instruction broadcasts the same value to all cells in the organism.

3200 BROADCAST    ; put 3200 in everybody's MESSAGE register

SAY

The SAY instruction will send a message (a single 16-bit value) to another organism. The recieving organism uses the RECV instruction to get the message. The message is sent along the noramlize direction vector to the firs thing it encounters.

46 1 -1 SAY

LISTEN

The LISTEN instruction will retrieve the MOOD register (a single 16-bit value) from another cell. The mood value is "heard" along the noramlize direction vector given by the (x,y) values on the data stack. The value of that other cell's MOOD register is put on this cells data stack.

1 -1 LISTEN		; retrieves the value 666

SHOUT

Why speak when you can shout? The SHOUT instruction broadcasts a message (a single 16-bit value) along all 8 directions. Any cell in line will recieve this message. The recieving organism uses the RECV instruction to get the message.

46 SHOUT

Interrupts

These communications instructions can be configured to interrupt the cell upon recieving a message. An interrupt uses the TRAP handlers to transfer control to a protected code block. See the mode flags for these instructions: SEND, BROADCAST, EAT, SEND-ENERGY, SHOUT, SAY, WRITE, KEY-PRESS.


WRITE

The WRITE instruction allows a cell to write data to another organism or spore (a spore is shown here).

0 1 2 8 WRITE pop    ; write code block 8 to spore at (0,1) code block 2

READ

The READ instruction allows a cell to read data from another organism or spore (a spore is shown here).

0 1 5 3 READ       ; read code block 5 from spore at (0,1) put data in code block 3

These instructions allows organism to communicate large amounts of data between each other. Also, spores can be used as storage devices to store and retrieve "files" of data. Note that these instructions can exchange code as well as data.

The READ/WRITE instructions give the simulator more core wars style parasitism and other tricks. Genetic information can be spread in this way without using the normal replication instructions.

The purpose of the READ/WRITE instructions is to fill out the computational model of Evolve 5.0 universe. It allows data to be exchanged akin to files or records in an operating system. I like to think of spores as "files" that you can place on the grid, much like an operating system lets you place files in the file system.


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:


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: