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

    where

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

    Formulas for basic effectors and receptors

    Neuron typeHow simulated
    | and @
    (muscles)
    Change the relative orientation of the joint's parts. Use the "standard-xyz" OpenGL visualization style to get some hints about axes and the orientation of creature's parts.
    • | (bending muscle) affects the Z axis
    • @ (rotating muscle) affects the X axis

    Parameters:

    • p (power) – muscle strength. Affects the movement velocity and the maximum force the muscle can create.
    • r (range) – for bending muscle only. Affects movement range, maximal value 1.0 means 360 degrees.
    G
    (gyroscope)
    state = (part1.z – part2.z) / stick_length
    T
    (touch)
    • 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)
    state = (sum_all_energy_sources[ energy / distance2 ])/100
    (if distance<1, then use 1)
    Water
    (water detector / water pressure indicator)
    • above surface: state = 0.0
    • below surface: state = depth
    Energy
    (energy level)
    • state = 1.0 for initial energy level (a newborn organism)
    • state = ... (intermediate values)
    • state = 0.0 for no energy (creature dies)