Population class in Global context

A set of Creature objects, sharing some high level simulation properties (performance calculation, NN simulation, collision detection, event handling). The groups usually have different roles in the experiment (Creatures groups and Food group in standard.expdef)

28 members:

integer bodysim
integer, 0 .. 1 (false/true)
default=1

Body simulation

Enable/disable physical body simulation. This is the initial value of Creature.bodysim for all objects created in this group. For details, see the documentation of Creature.bodysim.

integer colmask
integer, 0 .. 65535
default=0

Collision mask (deprecated)

DEPRECATED. You should use selfmask and othermask (these masks are also much easier to understand than the old colmask field).

integer death
integer, 0 .. 1 (false/true)
default=1

Death

Do creatures die when no energy?

float em_dyn
float, 0 .. 1
default=0

Muscle dynamic work

Energy requirements for a muscle
moving a stick

float em_stat
float, 0 .. 1
default=0

Muscle static work

Energy requirements for a muscle
resisting an external force

float en_assim
float, 0 .. 1
default=0

Assimilation productivity

Maximal energy gain produced by a vertical specialized stick.
Horizontal specialized sticks get half of this value.

integer enableperf
integer, 0 .. 2
  • 0 = Off
  • 1 = Immediate (default)
  • 2 = After stabilization
  • Performance calculation

    Stabilization means no significant movement during a specified period of time.

    integer energy
    integer, 0 .. 1 (false/true)
    default=1

    Energy calculation

    If turned off, creature's energy will be constant

    integer index
    integer

    group index

    integer killnostable
    integer, 0 .. 10000000
    default=1000000

    Kill if no stabilization after

    Creatures that fail to stabilize after the specified waiting period (e.g. because they are continuously rolling) will be killed. 0 disables this feature.

    string name
    string

    Group name

    integer nnsim
    integer, 0 .. 2
  • 0 = Off
  • 1 = Immediate (default)
  • 2 = After stabilization
  • Neural net simulation

    Stabilization means no significant movement during a specified period of time.

    integer othermask
    integer, 0 .. 2147483647
    default=0

    Collision mask (other)

    See selfmask.

    integer perfperiod
    integer, 0 .. 1000000
    default=100

    Performance sampling period

    Defines how often onUpdate() events are called. Also used to compute partial performance of creatures (distance, speed, etc.) and to determine stabilization.

    integer selfcol
    integer, 0 .. 1 (false/true)
    default=0

    Detect self-collisions

    Detect collisions within creature bodies (only applicable for the ODE simulation engine). This is the initial value of Creature.selfcol for all objects created in this group. If enabled, creatures with self-colliding genotypes are not born, and others will have their sticks collide during lifespan.

    integer selfmask
    integer, 0 .. 2147483647
    default=0

    Collision mask (self)

    Collisions between objects can be handled in two ways:
    - standard 'mechanical' collision (simple 'rebound' effect)
    - special script handler (On[GROUPNAME]Collision function)

    In the script handler function, use the Collision object to access the two colliding parts of two creatures.
    The first part in the Collision object (i.e. Collision.Creature1) always concerns the creature that belongs to [GROUPNAME].
    The handler is called once for each creature that collides with the creature from [GROUPNAME].

    Collision masks determine which one will be used (none and both are also possible). On each collision, selfmask and othermask of the colliding objects are logically ANDed. 16 lower bits (0xffff) enable the standard handler. 16 higher bits (0xffff0000) enable the custom handler.
    Examples:

    1.With one group, all possible combinations of the collision handlers are as follows:
    - ignore collisions (e.g. selfmask=othermask=0)
    - use standard handling (e.g. selfmask=othermask=1)
    - use custom handling (e.g. selfmask=othermask=0x10000)
    - use standard and custom handling (e.g. selfmask=othermask=0x10001)

    2.Two groups yield more interesting cases. Let us consider the 'standard.expdef' setting:
    Creatures: selfmask=0x10001, othermask=0x20001
    Food colmask = selfmask=0x20002, othermask=0x10002
    There are three possible scenarios:
    - creature and creature: collision value = 0x10001 & 0x20001 = 1 -> Standard handling will be used (1 is one of the lower 16 bits)
    - food and food: collision value = 0x20002 & 0x10002 = 2 -> As above.
    - creature and food: collision value = (0x10001 & 0x10002) or (0x20002 & 0x20001) = 0x10000 or 0x20000 -> Custom handling will be used (higher 16 bits).

    integer size
    integer

    Number of creatures

    integer stabilperiod
    integer, 0 .. 1000000
    default=100

    Sampling period while waiting

    "Performance sampling period" for the stabilization phase.

    float stabledist
    float, 0 .. 1
    default=0.01

    Allowed distance to be stable

    A creature is considered stabilized when its center of gravity stays within the specified distance after the "Sampling period while waiting" has elapsed.

    function createFromGeno
    returns Creature

    function createFromGeno(Geno)

    uses the supplied Geno object

    function createFromGenotype
    returns Creature

    function createFromGenotype()

    uses the selected Genotype object

    function createFromString
    returns Creature

    function createFromString(string genotype)

    uses the supplied string argument

    function delete
    doesn't return a value

    function delete(integer creature_index)

    delete creature

    function findCreatureAt
    returns Creature

    function findCreatureAt(Vector point, Vector vector)
    function findUID
    returns integer

    find creature by UID

    function findUID(string uid)
    function get
    returns Creature

    get creature object

    function get(integer index)
    function kill
    doesn't return a value

    function kill(integer creature_index)

    kill creature

    function senseCreaturesProperty
    returns float

    senseCreaturesProperty

    function senseCreaturesProperty(float x, float y, float z, string propertyname, Creature exclude)

    arguments:
    - x,y,z (sensor position)
    - property (name, name[index] or Class:id). name[index] can be used for Vector objects inside the user fields, eg "user2[10]"
    - exclude (creature object)
    works like a smell sensor for a given property (for all creatures in this group except "exclude").
    The following function reproduces the "classic" framsticks "S" sensor:
    function smellReceptorValue(x,y,z,exclude)
    {
    var i,s=0; for(i=0;i<Populations.size;i++)
    s+=Populations[0].senseCreaturesProperty(x,y,z,"energy",exclude);
    return s;
    }


    Global context