Simulator class, available in: Global contextThe Framsticks simulator.This class has 58 members:
sdleiFtnemirepxE
int running0 .. 1 (false/true)Is the simulation running?Useful for synchronizing the user interface state.
int timeNumber of stepsSimulator.time will be removed because of its misleading name, please use Simulator.stepNumber instead.
int last_genotype_num0 .. -1
default=0
Largest previously used Genotype.numSee: Genotype.num
int last_creature_num0 .. -1
default=0
Largest previously used Creature.numSee: Creature.num
int stepNumberNumber of simulation steps
int simspeed ROSimulation speedsteps/second
string expdefExperiment definitionChoose the experiment framework
(in Windows GUI, confirm by pressing 'Apply')

Stop the simulation before selecting another experiment definition.
It is a good practice to initialize the experiment before running the simulation.
string expdef_title ROTitle
multiline string expdef_info RODescription
untyped lastCheckpoint ROLast checkpointMost recently reported by the experiment definition script.
SlaveSimulators slaves ROSlave simulator objects
int cpus RONumber of detected CPUs ("cores") on this machine
World world ROWorld object
Populations populations ROPopulations object
GenePools genepools ROGene pools object
ExpProperties expproperties ROExpProperties
ExpState expstate ROExpState
GenMan genman ROGenMan object
GenoConverters genoconverters ROGenotype converters object
untyped userdataUser field
int identity ROIdentity-1 for master simulator, 0...count-1 for slaves
string version_string ROVersion stringCurrent application version as a string (human-friendly).
int version_int ROVersion integerCurrent application version as an integer.
seliF
int autosaveperiod0 .. 100000Save backupSave simulation state once every n-th event
(events are defined by the script. For 'standard.expdef' it is after each death).
Save EXPT file first to initialize name for autosave files.
Slave simulators (in multithreaded experiments) ignore this setting and never create autosave files.
int overwrite0 .. 1 (false/true)
default=0
Overwrite files?Lets you choose what to do when a file is created with the same name as an already existing file: overwite the existing file or create its backup?
int filecomm0 .. 1 (false/true)
default=1
Show file commentsControls displaying comments encountered in opened files.
gnitpircs decnavdA
multiline string usercodeScript overrideYou can override any function from the original experiment definition script. Use the same function names and provide alternative implementations.
Example:

function onBorn(cr)
{
Simulator.print("A creature is born: "+cr.name);
super_onBorn(cr); //calls the original implementation
}
int vmdebug0 .. 1 (false/true)VM debug
int vm_step_limit0 .. 1000000000
default=0
VM step limitAbort any script (expdef, fitness formula, user script) when it performs too many operations - which can take more or less time depending on your machine performance. This can protect against infinite loops or unbearably long runs of untested scripts that would otherwise force you to kill the whole application. Use Simulator.vm_..._warning if you only need information about what script takes too much time without aborting it.
int vm_step_warning0 .. 1000000000
default=0
VM step warningDisplay a warning when any script (expdef, fitness formula, user script) performs too many operations - which can take more or less time depending on your machine performance. Use Simulator.vm_..._limit to prevent the application from becoming unresponsive by aborting misbehaving scripts.
float vm_time_limit0 .. 1e+09
default=0.0
VM time limitAbort any script (expdef, fitness formula, user script) when it takes too much time - measured in seconds. The actual amount of work depends on your machine performance. This can protect against infinite loops or unbearably long runs of untested scripts that would otherwise force you to kill the whole application. Use Simulator.vm_..._warning if you only need information about what script takes too much time without aborting it.
float vm_time_warning0 .. 1e+09
default=0.0
VM time warningDisplay a warning when any script (expdef, fitness formula, user script) takes too much time - measured in seconds. The actual amount of work depends on your machine performance. Use Simulator.vm_..._limit to prevent the application from becoming unresponsive by aborting misbehaving scripts.
gnildnah rorrE
int stop_on0 .. 3
  • 0 = Don't stop
  • 1 = On warnings
  • 2 = On errors (default)
  • 3 = On critical errors
  • Error level to stop running simulationIf the simulation is running and a message is emitted with at least the selected severity, the simulation will be stopped.
    int createrr0 .. 2
  • 0 = Don't print (mute)
  • 1 = Print summary (default)
  • 2 = Print details
  • Object creation errors
    int groupchk0 .. 1 (false/true)
    default=1
    Warn on adding invalid genotypesWarnings will be printed when invalid genotypes are added to a gene pool.
    int creatwarnfail0 .. 1 (false/true)Don't simulate genotypes with warningsCreatures grown with warnings will not be simulated. This helps prevent the propagation of faulty genes, because genotypes that cause warnings when interpreted will not reproduce.
    snoitcnuF
    function beep()doesn't return a valueBeepPlays the default system sound.
    function checkpoint()doesn't return a valueNotify that the experiment state was significantly updated.This function was previously called "autosave".
    function checkpointData(untyped any_data)doesn't return a valueNotify that the experiment state was significantly updated + pass data.In the distributed/paralellized scenario the data passed as argument can be received by the controlling entity (onSlaveCheckpoint in multithreaded master experiment, /simulator/expevent in distributed network simulator).
    function eval(string script_statement)doesn't return a valueEvaluate a statementThe argument must be a complete statement, e.g. "return 2+2;" is valid, while "2+2" is not. The Error object is returned for invalid statements.
    Example:
    var statement="function fun(a) {return a*a;} return fun(Math.pi);";
    var result=Simulator.eval(statement);
    if (typeof result=="Error")
    Simulator.print("Error:"+result.message);
    else
    Simulator.print("Result:"+result);
    function export(string filename, int options, int genepool, int population)returns untypedExportSave some data to file. Arguments:
    - filename: can be null, which makes export() return saved data as a text string instead of writing it to the file.
    - options: composed of the following bit values:
        1 - experiment (works just like save() and all other option bits are ignored)
        2 - genotypes
        4 - simulator parameters
        8 - simulator stats
        16 - genepool settings
        32 - population settings
        64 - do autosave
        256 - creatures
    - selected genepool, -1 means all genepools
    - selected population, -1 means all populations
    function import(string filename, int options)doesn't return a valueimportImport some data from file. Contents can also be imported from string by using specifically formed filename: "string://string_contents_to_be_imported".
    The second optional argument selects what section(s) will be imported:
        1 - experiment (works just like load(), all other bits are ignored, and can reset the simulator state!)
        2 - genotypes
        4 - simulator parameters
        8 - genepool settings
        16 - population settings
        32 - new groups will be created for imported genepools and populations
        64 - allow switching to a different expdef while importing parameters (4)
        256 - creatures

    The standard behavior (without the second argument) is to import genotypes, parameters, and genepool and population settings (2+4+8+16). Note that "64" is not included by default, because the expdef change resets all simulator parameters, which contradicts the usual meaning of "import" in Framsticks ("add data", as opposed to "load" meaning "replace data"). Moreover, using the "64" option in scripts can be dangerous, especially all expdef and show scripts should always declare the proper expdef name in their header rather than change the expdef directly. Without the "64" option, it is always safe to "import" any file in a script regardless of the current simulator state.
    function import(string filename)doesn't return a valueImportEquivalent to import(filename,2+4+8+16) - imports genotypes, parameters, genepool and population settings.
    function init()doesn't return a valueInitialize experimentPrepares the experiment for running - usually performs initialization procedures such as resetting counters, states, gene pools, etc.
    These actions are defined in the onInit() function of this experiment definition.
    function load(string filename)doesn't return a valueloadLoad experiment file (calls onExpLoad() in the current experiment definition). This function is intended to replace the simulator state; the old state is cleared by automatically calling "resetToDefaults()". Use "import" if you don't want to lose the old simulator state. Contents can also be loaded from string by using specifically formed filename: "string://string_contents_to_be_loaded".
    function loadexpdef()doesn't return a valueReload experiment definitionResets the simulator to its default state, resets all parameters to default values and then loads this experiment definition.
    function message(string text, int level)doesn't return a valuePrint messageThe second argument can be:
    -1 = debugging message
    0 = information
    1 = warning
    2 = error
    3 = critical error
    function new()returns Simulatorcreate new Simulator
    function print(string text)doesn't return a valuePrint information messageOne argument: message to be printed.
    function refreshGUI()doesn't return a valueRefresh GUINotify that all populations and gene pools content changed.
    function reloadNeurons()doesn't return a valueReload neuron definitions
    function resetToDefaults()doesn't return a valueReset the simulator stateClears groups and loads default values for simulator parameters, then calls onExpDefLoad() of the current experiment definition.
    function save(string filename)returns untypedSaveSave experiment file (calls onExpSave() in the current experiment definition). Providing null filename makes save() return saved data as a text string instead of writing it to the file.
    function sleep(int milliseconds)doesn't return a valueSleepSuspends the execution for a specified interval.
    function sound(int freqency_in_Hz, int length_in_milliseconds)doesn't return a valueSoundGenerates a simple tone on the speaker
    function start()doesn't return a valueStart simulationCalled by the user interface.
    function step()doesn't return a valueDo a single simulation step
    function stop()doesn't return a valueStop simulationThe expdef script calls this function to stop simulation.
    Global context