Creature class, available in: Global contextThe object inside the simulated world, including its physical structure, neural network and performance data. Food pieces, obstacles and other movable objects can be implemented as Creatures even though the are not "alive".
Before version 4.0rc4 the static Creature object was used in event handlers and in functions operating on the "selected" creature. This is now deprecated as all operations can be performed using the more convenient direct access (see GenePools). For event handlers, the creature object will be passed as argument, like this:
function onDied(cr) {Simulator.print("Creature "+cr.name+" has died");}
See also: Population.
This class has 89 members:
sdleiFerutaerC
string nameName
multiline string genotype ROGenotype
multiline string infoInfoAdditional info or comments
untyped group ROcreature's PopulationDeprecated. Use population instead.
Population population ROcreature's population
int index ROcurrent index in populationNote that the index changes depending on the current creature position in the population. Use Creature.uid if you need a permanent identifier that persists through the entire object lifetime.
int numOrdinal numberActs as a unique identifier, but less strict than "uid". Unlike "uid", "num" can be changed and therefore can be saved and restored, providing persistence and continuity beyond a single application run. "num" is only guaranteed to be unique if it is autogenerated and not changed by the user, otherwise it is user's responsibility to manage the proper values of "num". Autogenerated "num" is always equal to the largest previously used "num" + 1. The largest previously used value is stored in Simulator.last_creature_num and can be changed as well (and is automatically saved and restored as a part of the Simulator state). Limitation: being a 32-bit integer, "num" overflows at about 2 billion counts.
See also: uid
int gnumGeneration
int buildproblemsBuild problems
XYZ driveEnforce constant speedMeasured in global coordinates.
XYZ driveLocalEnforce local constant speedMeasured in local coordinates, that is, with respect to the current orientation of the creature.
See also: Creature.orient
XYZ localDriveEnforce constant speedThis field is now called driveLocal.
Geno geno ROGenotypeSource genotype for this creature
Model model ROSource ModelSource Model for this creature
Model liveModel ROCurrent ModelA Model object that is a copy of the current (temporary) geometry of this creature
string uid RO#Unique identifier that is generated on object creation. "uid" is only unique during a single application run. Subsequent runs generate the same sequence of uid values.
See also: num
CreatureSignals signals ROSignal sources
ygrenE
float energ0Starting energy
float energy0Starting energy
float idleenIdle energy consumptionThe amount of energy subtracted from the energy of this creature in each simulation step, as in: cr.energy-=cr.idleen;
float energyEnergy
ecnamrofrep tnerruC
int perf0 .. 2
  • 0 = Off
  • 1 = On
  • 2 = Waiting for stabilization
  • Performance calculationReplaced by perf_measuring
    int perf_measuring0 .. 2
  • 0 = Off
  • 1 = On
  • 2 = Waiting for stabilization
  • Performance calculationThe initial value of this property is taken from Population.initial_perf_measuring
    int nnenabled0 .. 2
  • 0 = Off
  • 1 = On
  • 2 = Waiting for stabilization
  • NN enabledReplaced by nn_active
    int nn_active0 .. 2
  • 0 = Off
  • 1 = On
  • 2 = Waiting for stabilization
  • NN activeThe initial value of this property is taken from Population.nn_active
    int bodysim0 .. 1 (false/true)
    default=1
    Body simulationReplaced by physics_active
    int physics_active0 .. 1 (false/true)
    default=1
    Body simulation(Physical) body simulation can be disabled for individual objects which makes them immovable. Disabled objects can still participate in collisions depending on their collisions masks. The initial value of this property is taken from Population.initial_physics_active.

    Bugs: the standard collision handler does not work for disabled objects when ODE simulation is used. It means that these objects won't physically interact with other objects. The custom (scripting) handlers work as expected.
    int selfcol0 .. 1 (false/true)Self-collisionsReplaced by self_collisions
    int self_collisions0 .. 1 (false/true)Self-collisionsEnable/disable detection of self-collisions (within a creature body). They can only occur when using the ODE simulation engine. If enabled, the creature will have its sticks collide during lifespan. The initial value of this property is taken from Population.initial_self_collisions.
    int lifespanLifespanWhile the creature's performance measurement is enabled, the creature's lifespan is incremented in "performance sampling period" intervals.
    int steps_after_birthSimulation steps after birth"Birth" is the moment when the simulation of a creature starts.
    int steps_in_lifespanSimulation steps in lifespan"Lifespan" is the period during simulation of a creature when its performance measurement is enabled.
    float distanceDistanceSee http://www.framsticks.com/a/al_params.html#exper-perfcalc
    float c_velocityRecent period velocitySee http://www.framsticks.com/a/al_params.html#exper-perfcalc
    float c_vertvelocityRecent period vertical velocitySee http://www.framsticks.com/a/al_params.html#exper-perfcalc
    float c_vertposRecent period vertical positionSee http://www.framsticks.com/a/al_params.html#exper-perfcalc
    Dictionary dataCustom fields dictionary
    untyped user1User field 1
    untyped user2User field 2
    untyped user3User field 3
    ecnamrofrep egarevA
    float velocityAverage velocitySee http://www.framsticks.com/a/al_params.html#exper-perfcalc
    float vertposAverage vertical positionSee http://www.framsticks.com/a/al_params.html#exper-perfcalc
    float vertvelAverage vertical velocitySee http://www.framsticks.com/a/al_params.html#exper-perfcalc
    yrtemoeG
    float pos_x ROPosition x(pos_x,pos_y,pos_z) is the point of minimal coordinates ("bottom left corner") of the creature, including imaginary Part sizes (Part.s, usually 1.0). See also: Creature.moveAbs
    float pos_y ROPosition ySee Creature.pos_x
    float pos_z ROPosition zSee Creature.pos_x
    float size_x ROBounding box x size(size_x,size_y,size_z) are dimensions of the axis-aligned bounding box of the creature, including the imaginary part sizes (Part.s, usually 1.0). A creature consisting of a single default Part has the size of (2.0,2.0,2.0) - twice the Part.s value (like a sphere diameter is twice its radius).
    See also: Creature.moveAbs
    float size_y ROBounding box y sizeSee Creature.size_x
    float size_z ROBounding box z sizeSee Creature.size_x
    float center_x ROcenter.xCenter of gravity
    float center_y ROcenter.yCenter of gravity
    float center_z ROcenter.zCenter of gravity
    XYZ bboxLow ROBounding box "low" corner
    XYZ bboxHigh ROBounding box "high" corner
    XYZ bboxCenter ROBounding box center
    XYZ bboxSize ROBounding box size
    float bboxGroundOffset ROBounding box ground offsetDue to multiple modes of simulation and Part shapes, you need to add this value to the intended creature bottom elevation to get the 'z' coordinate of the bboxLow that places the creature exactly on the specific height level.
    Example:
    creature.locationSetBboxLow(10,10,0+creature.bboxGroundOffset); //bottom of the crearture will be at level 0 on a flat ground
    XYZ centerOfGravity ROCenter of gravitySee http://www.framsticks.com/a/al_params.html#exper-perfcalc
    int numparts RONumber of body Parts
    int numjoints RONumber of body Joints
    int numneurons RONumber of neurons
    int numconnections RONumber of neural connections
    Orient orient ROOrientationBy convention, the orientation of the creature is equal to the orientation of its first Part.
    untyped outdated_neuro_classes ROOutdated neuro classesNames of the neuron classes that have been modified after this creature was built
    int selfmask0 .. 2147483647
    default=0
    Collision mask (self)Creature's selfmask is set according to the Creature's Population.selfmask. See Population.selfmask for detailed information about collision handling.
    int othermask0 .. 2147483647
    default=0
    Collision mask (other)Creature's othermask is set according to the Creature's Population.othermask. See Population.selfmask for detailed information about collision handling.
    snoitcnuF
    function boundingBoxCollisions(int mask)returns intCheck bounding box collisionsChecks approximate collisions for the selected creature.
    Returns the collision mask calculated as ( mask & colliding_creatures.othermask ). Usually called with mask=0, which has the special meaning of using the current creature.selmask instead of 0, so that it detects the same type of collisions as the current experiment configuration.
    Passing non-zero mask value uses it instead of creature.selfmask, allowing you to include or exclude other colliding populations, as if creature.selfmask were modified temporarily.
    function checkCollisions(int mask, int accuracy)returns untypedCheck collisionsReturns zero if the creature does not collide with other creatures.
    Arguments:
    - mask: if not zero, temporarily replaces creature.selfmask. For details see boundingBoxCollisions()
    - accuracy:
    0 = testing creature bounding boxes
    1 = testing creature elements
    function getJoint(int index)returns JointGet Joint (static Model information)
    function getMechJoint(int index)returns MechJointGet MechJoint (current properties)
    function getMechPart(int index)returns MechPartGet MechPart (current properties)
    function getNeuro(int index)returns NeuroGet Neuro
    function getNeuroDef(int index)returns NeuroDefGet NeuroDef
    function getPart(int index)returns PartGet Part (static Model information)
    function localToWorld(float x, float y, float z)returns XYZReturn world coordinatesLocal coordinates are measured with respect to the position and orientation of the first Part.
    function locationMoveBy(float dx, float dy, float dz)doesn't return a valueMove by a vectorShift the creature by a given vector (in world coordinates).
    function locationMoveLocalBy(float dx, float dy, float dz)doesn't return a valueMove by a vector in local coordinatesLocal coordinates are measured with respect to the position and orientation of the first Part.
    function locationSetBboxCenter(float x, float y, float z)doesn't return a valueMove bounding box center to absolute locationMoves the creature as determined by the center of the bounding box of a creature.
    function locationSetBboxLow(float x, float y, float z)doesn't return a valueMove bounding box corner to absolute locationMoves the creature as determined by the "low" corner (the one with the lower coordinate values) of the bounding box of a creature.
    function move(float dx, float dy, float dz)doesn't return a valueMove by a vectorReplaced by locationMoveBy().
    function moveAbs(float x, float y, float z)doesn't return a valueMove to absolute locationReplaced by locationSetBboxLow().
    function moveLocal(float dx, float dy, float dz)doesn't return a valueMove by a vector in local coordinatesReplaced by locationMoveLocalBy
    function rotate(float x, float y, float z)doesn't return a valueRotateRotate the creature around X, Y and Z axes. Should only be used immediately after creating a new creature (before the first simulation step is performed for this creature), otherwise further simulation can be disturbed.
    function rotateLocal(float x, float y, float z)doesn't return a valueRotate in local coordinatesRotate the creature around (local) X, Y and Z axes. Should only be used immediately after creating a new creature (before the first simulation step is performed for this creature), otherwise further simulation can be disturbed.
    function selfCollisionsCount()returns intCurrent self-collisions stateReturns the number of self-collisions detected in the creature.
    function selfcolstate()returns intSelf-collisionsReplaced by selfCollisionsCount()
    function transferEnergyTo(Creature recipient, float requested_amount_of_energy)returns floatTransfer energyTransfers at most the requested_amount_of_energy from this creature to the recipient. Returns the amount of energy actually transferred.
    The function will only transfer positive amounts and will not transfer more energy than this creature has, so the function is equivalent to:
    if (this.energy>0 && requested_amount_of_energy>0)
    {
    var amount = Math.min(requested_amount_of_energy, this.energy);
    recipient.energy += amount;
    this.energy -= amount;
    }

    Calling this function from inside the collision handler to transfer energy between colliding parts automatically adds the relevant MechPart references, as if transferEnergyToPart was called, i.e.
        Collision.Creature1.transferEnergyTo(Collision.Creature2, e);
    is equivalent to:
        Collision.Creature1.transferEnergyToPart(Collision.Part1, Collision.Creature2, Collision.Part2, e);
    When this behavior is not intended, explicit nulls in transferEnergyToPart() can be used to avoid associating the energy transfer with the currently colliding parts, like this:
        Collision.Creature1.transferEnergyToPart(null, Collision.Creature2, null, e);
    function transferEnergyToPart(MechPart source_part, Creature recipient_creature, MechPart recipient_part, float requested_amount_of_energy)returns floatTransfer energyTransfer energy between specific parts of two creatures. Part arguments are only used for visualization and can be null, which would mean "the entire creature".
    See also: transferEnergyTo()
    function worldToLocal(float x, float y, float z)returns XYZReturn local coordinatesLocal coordinates are measured with respect to the position and orientation of the first Part.
    Global context