Simulation Details 

Physical (creature's body) simulation

Bodies of creatures are divided into small pieces (at sticks' ends) which are ideal material points. This approach is called "finite element method": not every point of a material body is simulated – only a finite number of points, representing small volumes in the body. The simulator calculates all the forces affecting a given point: gravity, elastic reaction when joined with other points, ground reaction and friction when touching the ground, etc.

In our model some assumptions are taken to simplify calculations. A primitive but fast numeric integration method is used, so the results are not very exact when dealing with big forces.

The picture on the right shows sample forces calculated in the Framsticks physical simulator, Mechastick.

The body is made from parts (points) and joints (sticks, rods).




Neural (creature's brain) simulation

Neural network is made from neurons and connections. The Framsticks simulator supports many types of neurons (for example sigmoid neuron N, noise generator Rnd, differential neuron D, delay neuron Delay, threshold neuron Thr), and users can easily create their own signal processing neurons using FramScript and editing scripts/*.neuro files.

Formulas for neurons: N, Nu, D, Thr, *, Rnd, Sin, Fuzzy

Note: For most neurons, multiple inputs do not have idividual meaning and are aggregated with respect to their weights (weighted sum is computed).

Neuron type How simulated
N and Nu
(sigmoid neurons)

In each simulation step:

#define NEURO_MAX 10.0
input=getWeightedInputSum();
velocity=force*(input-state)+inertia*velocity;
state+=velocity;
if (state>NEURO_MAX) state=NEURO_MAX;
else if (state<-NEURO_MAX) state=-NEURO_MAX;
tmp=state * sigmo;
N
if (tmp<-30.0) output = -1;          //safer than exp(-tmp)
          else output = (2.0/(1.0+exp(-tmp))-1.0); // -1..1
Nu
if (tmp<-30.0) output = 0;           //safer than exp(-tmp)
          else output = (1.0/(1.0+exp(-tmp)));     //  0..1

  • state, velocity – internal variables
  • sigmo, force, inertia – neuron parameters (properties)
  • input, tmp – temporary variables
    D
    (differentiate)
    Calculate the difference between the current and the previous input values.
    Thr
    (threshold)
    Outputs lo if the input signal is below the t threshold. Outputs hi otherwise.

    t, lo and hi are parameters.

    *
    (constant output)
    Outputs the value of 1.
    Rnd
    (random noise)
    Outputs random values (uniform distribution) in the range of –1..+1
    Sin
    (sinus generator)

    The output sinusoid has frequency f and initial phase t. The output frequency depends on the neuron input value. Parameters:

    • f0 (base frequency). The output frequency f = f0 + current_neuron_input_value.
    • t (time) – initial phase.
    Fuzzy
    (fuzzy control system)
    See this paper for details; see this movie for demonstration.

The N neuron in detail

Sigmoid neurons (with short name N) use a simple weighted sum of input signals. Excitation influences neuron state, which has some inertia. Stronger signals can change the state faster than weak signals. Output is flattened to a [-1,+1] range using basic sigmoidal function. See examples below: (input/state/output)

Simple excitation. The state goes up when the input is positive and falls down when theinput reaches zero. Note that in this example the neuron's state can fall below zero due to its inertia.
Short but strong impulse gives similar results to a weak and long one.
In this example a strong signal causes saturation of the neuron (its state goes very high). Later signal changes do not influence the output.

N parameters

The 'N' neuron has three properties (parameters) which influence its behavior:
  • Force, noted as 'fo', value range: 0..1, default 0.04
  • Inertia, noted as 'in', value range: 0..1, default 0.8
  • Sigmoid, noted as 'si', any real number accepted, default 2.0
Force and inertia influence changes of the inner neuron state. In each simulation step, the neuron state is modified towards the value calculated from input excitations. Force determines how fast the value is changed. Maximum value of 1.0 gives instant reaction. Low values, like the default (0.04) cause smooth 'charging' and 'discharging' of the neuron. Neuron's inertia is similar to the physical inertia of a body: it sustains its state change tendency. Low inertia values have very little influence on the state. Values near the maximum (1.0) can result in oscillations of the neuron state. The following pictures show sample usage of these parameters (input/state/output).
Force=0.1, inertia=0
Slow state change. Note the instant reaction after the input signal pulse when inertia is disabled.
Force=0.1, inertia=0.8
With inertia enabled, the neuron's state rises above the input pulse amplitude, and then drops below zero. The final state is achieved after several oscillations.
Force=1, inertia=0
Maximum force coefficient results in an instant input to output propagation.

The third, sigmoid coefficient changes the output function. Detailed formulas which describe the work of the N neuron are as follows:

    velocityt = velocityt–1
    inertia + force
    (inputtstatet–1)

    statet = statet–1 + velocityt

    outputt =
    2

    1 + e (-velocityt
    sigmoid)
    – 1
    where
    input: weighted sum of neuron inputs,
    velocity: analogous to physical velocity,
    state: internal state (analogous to physical location),
    output: output signal.
    Subscripts represent the time moment.

    The following pictures show sample usage of the sigmoid parameter.

    Sigmoid=2.0
    Default.
    Sigmoid=10.0
    High values nearly produce a threshold function.
    Sigmoid=0.5
    Low values give a nearly linear output function.



    Special neurons: muscles and receptors

    Basic muscles (actuators) and receptors (sensors) are illustrated below.

    A muscle neuron ('|' or '@' in genotype) can change the relative orientation of the controlled stick (relative to the previous stick).
    This simple 2-stick creature with a bending muscle in the middle is described by the genotype "XX[|...]". The joint stays straight when the signal is equal to 0. Positive and negative values bend the constructon in the opposite directions. [animation]
    The "G" receptor (gyroscope, equilibrium sense) gives information about the stick's orientation relative to the gravity force. A gyroscope mounted on a horizontally aligned stick sends 0 to its outputs. Vertical position is perceived as -1 or +1 depending on which end is higher. [animation]
    The "T" receptor (touch) can be imagined as a whisker attached to the stick. Its relaxed state is -1 (nothing detected in the whiskers' range). The signal value grows as the stick gets closer to any material object. Reaches 0 when the stick touches the ground. Higher values mean that the stick is pushed into the ground. [animation]
    The "S" receptor (smell) excitation depends on the sum of the neighbor energy sources (energy balls and other creatures). Output range is from 0 (nothing detected) to 1 (maximum). Rich or closer energy sources smell 'stronger' than small or distant ones. [animation]

    Formulas for basic effectors and receptors

    Neuron type How simulated
    | (muscle)

    [animation]
    Changes the relative orientation of the joint's parts by rotating the second part around the first part's Z axis. Parameters:
    • p (power) – muscle strength. Affects the movement velocity and the maximum force the muscle can exert.
    • r (range) – Affects movement range, maximal value 1.0 means full range (-180°..+180°). The following rule applies:
      Angle = Range * Signal * 180°
      
    Sample creature (f1 genotype XX[|])
    //0
    p:
    p:1, m=2
    p:2
    j:0, 1, dx=1
    j:1, 2, dx=1
    n:j=1, d=|
    

    Neutral position
    Singal = 0
    Angle = 0°

    Muscle active
    Signal = 0.2
    Angle = 36°

    Explanation: The joint is attached to parts #1 and #2. Part #2 was rotated around the Z axis of Part #1, so its position and orientation was changed.

    The above pictures were created using the "standard-xyz" OpenGL visualization style, which can be used to investigate part orientations in creatures.

    @ (muscle) Changes the relative orientation of the joint's parts by rotating the second part around the first part's X axis. Parameters:
    • p (power) – muscle strength. Affects the movement velocity and the maximum force the muscle can exert.
    This musle always uses the full movement range (-180°..+180°).
    Angle = Signal * 180°
    

    Sample creature (f1 genotype XX[@])
    //0
    p:
    p:1, m=2
    p:2
    j:0, 1, dx=1
    j:1, 2, dx=1
    n:j=1, d=@
    

    Neutral position
    Singal = 0
    Angle = 0°

    Muscle active
    Signal = 0.25
    Angle = 45°

    Explanation: The joint is attached to parts #1 and #2. Part #2 was rotated around the X axis of Part #1. Part #2 was not moved, because it lies on the X axis (in creatures built from f1 genotypes, all parts lie on the X axis).

    The above pictures were created using the "standard-xyz" OpenGL visualization style, which can be used to investigate part orientations in creatures.

    G
    (gyroscope)

    [animation]
    state = (part1.z – part2.z) / stick_length
    T
    (touch)

    [animation]
    • if touches: state = distance of part and ground (which is equivalent to positive depth)
    • if does not touch: check along x orientation of the part
      • state = –1.0 if there are no objects closer than 1.0 distance
      • state = ... (intermediate negative values)
      • state = 0.0 if a touched object is just at the T part
    S
    (smell)

    [animation]
    state = (sum_all_energy_sources[ energy / distance2 ])/100
    (if distance<1, then use 1)
    Water
    (water detector / water pressure indicator)

    [animation]
    • above surface: state = 0.0
    • below surface: state = depth
    Energy
    (energy level)

    [animation]
    • state = 1.0 for initial energy level (a newborn organism)
    • state = ... (intermediate values)
    • state = 0.0 for no energy (creature dies)

    All neuron types: summary

    N (Neuron)

    Standard neuron

       supports any number of inputs
       provides output value
       does not require location in body
    
    Properties:
       Inertia (in) float 0..1
       Force (fo) float 0..999
       Sigmoid (si) float -99999..99999
       State (s) float -1..1
    

    G (Gyroscope)

    Equilibrium sensor.
    0=the stick is horizontal
    +1/-1=the stick is vertical

       does not use inputs
       provides output value
       should be located on a Joint
    

    T (Touch)

    Touch sensor.
    -1=no contact
    0=just touching
    >0=pressing, value depends on the force applied

       does not use inputs
       provides output value
       should be located on a Part
    

    S (Smell)

    Smell sensor. Aggregated "smell of energy" experienced from all energy objects (creatures and food pieces).
    Close objects have bigger influence than the distant ones: for each energy source, its partial feeling is proportional to its energy/(distance^2)

       does not use inputs
       provides output value
       should be located on a Part
    

    * (Constant)

    Constant value

       does not use inputs
       provides output value
       does not require location in body
    

    | (Bend muscle)

       uses single input
       does not provide output value
       should be located on a Joint
    
    Properties:
       power (p) float 0.01..1
       rot.range (r) float 0..1
    

    @ (Rotation muscle)

       uses single input
       does not provide output value
       should be located on a Joint
    
    Properties:
       power (p) float 0.01..1
    

    D (Differentiate)

    Calculate the difference between the current and previous input value. Multiple inputs are aggregated with respect to their weights

       supports any number of inputs
       provides output value
       does not require location in body
    

    Water (Water detector)

    Output signal:
    0=on or above water surface
    1=under water (deeper than 1)
    0..1=in the transient area just below water surface

       does not use inputs
       provides output value
       should be located on a Part
    

    Energy (Energy level)

    The current energy level divided by the initial energy level.
    Usually falls from initial 1.0 down to 0.0 and then the creature dies. It can rise above 1.0 if enough food is ingested

       does not use inputs
       provides output value
       does not require location in body
    

    Ch (Channelize)

    Combines all input signals into a single multichannel output; Note: ChSel and ChMux are the only neurons which support multiple channels. Other neurons discard everything except the first channel.

       supports any number of inputs
       provides output value
       does not require location in body
    

    ChMux (Channel multiplexer)

    Outputs the selected channel from the second (multichannel) input. The first input is used as the selector value (-1=select first channel, .., 1=last channel)

       uses 2 inputs
       provides output value
       does not require location in body
    

    ChSel (Channel selector)

    Outputs a single channel (selected by the "ch" parameter) from multichannel input

       uses single input
       provides output value
       does not require location in body
    
    Properties:
       channel (ch) integer
    

    Rnd (Random noise)

    Generates random noise (subsequent random values in the range of -1..+1)

       does not use inputs
       provides output value
       does not require location in body
    

    Sin (Sinus generator)

    Output frequency = f0+input

       uses single input
       provides output value
       does not require location in body
    
    Properties:
       base frequency (f0) float -1..1
       time (t) float 0..6.28319
    

    Delay (Delay)

       uses single input
       provides output value
       does not require location in body
    
    Properties:
       delay time (t) integer 1..1000
    

    Nn (Noisy neuron)

    Propagates weighted inputs onto the output, but occassionally generates a random value

       supports any number of inputs
       provides output value
       does not require location in body
    
    Properties:
       Error rate (e) float 0..0.1
    

    Sf (Smell food)

    Detects only food, not other creatures
    (in experiments with food in group #1)

       does not use inputs
       provides output value
       should be located on a Part
    

    Thr (Threshold)

    if (input>=t) then output=hi else output=lo

       uses single input
       provides output value
       does not require location in body
    
    Properties:
       threshold (t) float
       low output value (lo) float
       high output value (hi) float
    

    Experimental neurons

    Do not use unless you know what you are doing. Some of these neurons can be unstable, many are used for special purposes.

    Nu (Unipolar neuron [EXPERIMENTAL!])

    Works like standard neuron (N) but the output value is scaled to 0...+1 instead of -1...+1.
    Having 0 as one of the saturation states should help in "gate circuits", where input signal is passed through or blocked depending on the other singal.

       supports any number of inputs
       provides output value
       does not require location in body
    
    Properties:
       Inertia (in) float 0..1
       Force (fo) float 0..999
       Sigmoid (si) float -99999..99999
       State (s) float -1..1
    

    Fuzzy (Fuzzy system [EXPERIMENTAL!])

    Refer to publications to learn about this neuron

       supports any number of inputs
       provides output value
       does not require location in body
    
    Properties:
       number of fuzzy sets (ns) integer
       number of rules (nr) integer
       fuzzy sets (fs) string
       fuzzy rules (fr) string
    

    VEye (Vector Eye [EXPERIMENTAL!])

       uses single input
       provides output value
       should be located on a Part
    
    Properties:
       target.x (tx) float
       target.y (ty) float
       target.z (tz) float
       target shape (ts) string
       perspective (p) float 0.1..10
       scale (s) float 0.1..100
       show hidden lines (h) integer 0..1
       output lines count (each line needs four channels) (o) integer 0..99
       debug (d) integer 0..1
    

    VMotor (Visual-Motor Cortex [EXPERIMENTAL!])

    Must be connected to the VEye and properly set up.

       supports any number of inputs
       provides output value
       does not require location in body
    
    Properties:
       number of basic features (noIF) integer
       number of degrees of freedom (noDim) integer
       parameters (params) string
    

    Sti (Sticky [EXPERIMENTAL!])

       uses single input
       does not provide output value
       should be located on a Part
    

    LMu (Length muscle [EXPERIMENTAL!])

       uses single input
       does not provide output value
       should be located on a Joint
    
    Properties:
       power (p) float 0.01..1
    
 
 
 
On the forum: