Changeset 1158


Ignore:
Timestamp:
10/01/21 23:40:49 (2 years ago)
Author:
Maciej Komosinski
Message:

Cosmetic/minor improvements

Files:
17 edited
1 moved

Legend:

Unmodified
Added
Removed
  • cpp/common/threads.h

    r665 r1158  
    2727        pthread_key_t mt_key;
    2828        bool destroyed;
    29        
     29
    3030public:
    3131
     
    3333        {
    3434                pthread_key_create(&mt_key, &destructor);
    35                 destroyed=false;
     35                destroyed = false;
    3636        }
    3737
     
    4040                T* o = set(NULL);
    4141                if (o) delete o;
    42                 destroyed=true;
     42                destroyed = true;
    4343        }
    4444
     
    114114        T *object;
    115115public:
    116         ThreadSingletonPtr():object(NULL) {}
    117         T* get() {return object;}
    118         T* setptr(T* o) {T* previous=object; object=o; return previous;}
     116        ThreadSingletonPtr() :object(NULL) {}
     117        T* get() { return object; }
     118        T* setptr(T* o) { T* previous = object; object = o; return previous; }
    119119};
    120120
     
    139139{
    140140        if (!var)
    141                 var=new T();
     141                var = new T();
    142142        return var;
    143143}
     
    151151#define tlsGetRef(var) (*_tlsGet(ThreadLocal_ ## var))
    152152
    153 template<class T> T* _tlsSet(T*& var,T* new_o)
     153template<class T> T* _tlsSet(T*& var, T* new_o)
    154154{
    155         T* o=var;
    156         var=new_o;
     155        T* o = var;
     156        var = new_o;
    157157        return o;
    158158}
  • cpp/frams/Makefile-SDK

    r1035 r1158  
    1111CXXWARNINGS=-Wall -Wno-parentheses -Wno-overloaded-virtual -Wno-format -Werror=return-type
    1212
    13 SDK_BUILD_CONFIG= -include frams/config/sdk_build_config.h
     13SDK_BUILD_CONFIG= -include frams/config/sdk-build-config.h
    1414CXXFLAGS= -I$(CURDIR) -std=gnu++17 $(SDK_BUILD_CONFIG) $(CXXWARNINGS) -g
    1515
  • cpp/frams/frams-objects.h

    r1123 r1158  
    2525EXPORTED char* extPropId(void *v, int i);
    2626EXPORTED char* extPropType(void *v, int i);
     27EXPORTED char* extPropName(void *v, int i);
     28EXPORTED int extPropFlags(void *v, int i);
     29EXPORTED int extPropGroup(void *v, int i);
     30EXPORTED char* extPropHelp(void *v, int i);
    2731EXPORTED int extPropFind(void *v, char* id);
    2832EXPORTED void* extPropGet(void *v, int i);
    2933EXPORTED int extPropSet(void *v, int i, void* e);
    3034EXPORTED void* extPropCall(void *v, int i, int argc, void* argv);
     35EXPORTED int extGroupCount(void *v);
     36EXPORTED char* extGroupName(void *v, int i);
     37EXPORTED int extGroupMember(void *v, int g, int i);
     38EXPORTED int extMemberCount(void *v, int g);
    3139EXPORTED void* rootObject();
    3240
  • cpp/frams/genetics/fS/fS_general.h

    r1032 r1158  
    11// This file is a part of Framsticks SDK.  http://www.framsticks.com/
    2 // Copyright (C) 2019-2020  Maciej Komosinski and Szymon Ulatowski.
     2// Copyright (C) 2019-2021  Maciej Komosinski and Szymon Ulatowski.
    33// See LICENSE.txt for details.
    44
     
    1111#include <unordered_map>
    1212#include <exception>
     13#include <algorithm>
    1314#include "frams/model/model.h"
    1415#include "frams/util/multirange.h"
  • cpp/frams/model/geometry/modelgeoclass.cpp

    r1115 r1158  
    1818        "To set geom_density for individual ModelGeometry objects:\n"
    1919        "var mg=ModelGeometry.forModel(GenePools[0][0].getModel()); mg.geom_density=2; GenePools[0][0].data->area=mg.area();\n" },
    20         { "geom_density", 0, 0, "Density", "f 0.01 100.0 1.0", FIELD(density), "The number of samples (per unit length in one dimension) that affects the precision of estimation of geometrical properties." }, //note: we used 'geom_density' instead of 'density' to make the name more unique - because sim_params merges all configuration fields in a single namespace.
     20        { "geom_density", 0, 0, "Density", "f 0.01 100.0 3.0", FIELD(density), "The number of samples (per unit length in one dimension) that affects the precision of estimation of geometrical properties." }, //Note #1: we used 'geom_density' instead of 'density' to make the name more unique - because sim_params merges all configuration fields in a single namespace. Note #2: "density" needs better, more interpretable and more reliable parametrization for surface sampling...
    2121        { "forModel", 0, PARAM_USERHIDDEN, "", "p oModelGeometry(oModel)", PROCEDURE(p_formodel), "The returned ModelGeometry object can be used to calculate geometric properties (volume, area, sizes) of the associated model. The density is copied from the current global ModelGeometry.geom_density on object creation." },
    2222        { "volume", 0, PARAM_NOSTATIC | PARAM_USERHIDDEN, "volume", "p f()", PROCEDURE(p_volume), },
  • cpp/frams/model/modelobj.cpp

    r999 r1158  
    2121        { "numconnections", 0, PARAM_DONTSAVE | PARAM_NOSTATIC | PARAM_READONLY, "Number of neuron connections", "d", GETONLY(numconnections), },
    2222
    23         { "getPart", 0, PARAM_USERHIDDEN | PARAM_NOSTATIC, "getPart (static model information)", "p oPart(d index)", PROCEDURE(p_getpart), },
    24         { "getJoint", 0, PARAM_USERHIDDEN | PARAM_NOSTATIC, "getJoint (static model information)", "p oJoint(d index)", PROCEDURE(p_getjoint), },
    25         { "getNeuroDef", 0, PARAM_USERHIDDEN | PARAM_NOSTATIC, "getNeuroDef", "p oNeuroDef(d index)", PROCEDURE(p_getneuro), },
     23        { "getPart", 0, PARAM_READONLY | PARAM_USERHIDDEN | PARAM_NOSTATIC, "getPart (static model information)", "p oPart(d index)", PROCEDURE(p_getpart), },
     24        { "getJoint", 0, PARAM_READONLY | PARAM_USERHIDDEN | PARAM_NOSTATIC, "getJoint (static model information)", "p oJoint(d index)", PROCEDURE(p_getjoint), },
     25        { "getNeuroDef", 0, PARAM_READONLY | PARAM_USERHIDDEN | PARAM_NOSTATIC, "getNeuroDef", "p oNeuroDef(d index)", PROCEDURE(p_getneuro), },
    2626
    2727        { "size_x", 0, PARAM_READONLY | PARAM_NOSTATIC | PARAM_DEPRECATED, "Bounding box x size", "f", FIELD(size.x), "(size_x,size_y,size_z) are dimensions of the axis-aligned bounding box of the creature, including 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).\nSee also: Creature.moveAbs" },
     
    3030        { "bboxSize", 0, PARAM_READONLY | PARAM_NOSTATIC, "Bounding box size", "oXYZ", GETONLY(bboxsize) },
    3131        { "numcheckpoints", 0, PARAM_DONTSAVE | PARAM_READONLY | PARAM_NOSTATIC, "Number of checkpoints", "d", GETONLY(numcheckpoints) },
    32         { "getCheckpoint", 0, PARAM_USERHIDDEN | PARAM_NOSTATIC, "getCheckpoint", "p oModel(d index)", PROCEDURE(p_getcheckpoint),
     32        { "getCheckpoint", 0, PARAM_READONLY | PARAM_USERHIDDEN | PARAM_NOSTATIC, "getCheckpoint", "p oModel(d index)", PROCEDURE(p_getcheckpoint),
    3333        "Checkpoint Model objects are only valid as long as the parent Model object exists.\n"
    3434        "See also: Model.newWithCheckpoints()\n\n"
  • cpp/frams/model/similarity/measure-greedy.cpp

    r1073 r1158  
    11// This file is a part of Framsticks SDK.  http://www.framsticks.com/
    2 // Copyright (C) 1999-2020  Maciej Komosinski and Szymon Ulatowski.
     2// Copyright (C) 1999-2021  Maciej Komosinski and Szymon Ulatowski.
    33// See LICENSE.txt for details.
    44
    55#include "measure-greedy.h"
     6#include <cstdlib> //std::qsort()
    67#include <assert.h>
    78
  • cpp/frams/neuro/impl/neuroimpl-fuzzy.cpp

    r1130 r1158  
    55#include "neuroimpl-fuzzy.h"
    66#include "neuroimpl-fuzzy-f0.h"
     7#include <algorithm>
    78
    89int NI_FuzzyNeuro::countOuts(const Model *m, const Neuro *fuzzy)
  • cpp/frams/util/extvalue.h

    r1130 r1158  
    4343class ExtObject
    4444{
    45         int subtype;                    //< 0/1=Generic/DPC Object,  0/2=Standalone/Shared Param
     45        int subtype;                    //< 0/1=Generic/DPC Object,  0/2=Standalone/Shared Param,  0/4=RW/Readonly
    4646        void incref() const;
    4747        void decref() const;
     
    7373        void setEmpty() { decref(); subtype = 0; param = NULL; object = NULL; }
    7474        int isEmpty() const { return !param; }
     75        bool isReadonly() const {return (subtype&4)!=0;}
     76        void setReadonly(bool ro) {subtype=(subtype&~4)|(ro?4:0);}
    7577        static const ExtObject& empty() { static const ExtObject e((ParamInterface*)NULL); return e; }
    7678        ExtObject(const ExtObject& src) { DEBUG_EXTOBJECT("(const&)"); src.incref(); copyFrom(src); }
     
    188190        void setInvalid() { setEmpty(); type = TInvalid; }
    189191        void setError(const SString& msg);
     192        bool isReadonly() const {return (type==TObj) && odata().isReadonly();}
     193        void setReadonly(bool ro) {if (type==TObj) odata().setReadonly(ro);}
    190194        bool makeUnique() { return (type == TObj) && odata().makeUnique(); } //< @return false if nothing has changed
    191195        ExtPType getType() const { return type; }
  • cpp/frams/vm/classes/3dobject.cpp

    r951 r1158  
    2020                { "new", 0, 0, "create new XYZ object", "p oXYZ(f x,f y,f z)", PROCEDURE(p_new), "3D vectors objects can be also created using the (x,y,z) notation, i.e. var v=(1,2,3) is the same as var v=XYZ.new(1,2,3);", },
    2121                { "newFromVector", 0, 0, "create new XYZ object", "p oXYZ(oVector)", PROCEDURE(p_newFromVector), "used for deserialization" },
    22                 { "clone", 0, PARAM_NOSTATIC, "create new XYZ object copying the coordinates", "p oXYZ()", PROCEDURE(p_clone), "Note: copying object references does not create new objects. Use clone() if a new object is needed.\n\nExample:\nvar o1=(1,2,3), o2=o1, o3=o1.clone();\no1.y=9999;\n//o2 is now (1,9999,3) but o3 is still (1,2,3)", },
     22                { "clone", 0, PARAM_READONLY | PARAM_NOSTATIC, "create new XYZ object copying the coordinates", "p oXYZ()", PROCEDURE(p_clone), "Note: copying object references does not create new objects. Use clone() if a new object is needed.\n\nExample:\nvar o1=(1,2,3), o2=o1, o3=o1.clone();\no1.y=9999;\n//o2 is now (1,9999,3) but o3 is still (1,2,3)", },
    2323                { "set", 0, PARAM_NOSTATIC, "set (copy) coordinates from another XYZ object", "p(oXYZ)", PROCEDURE(p_set), },
    2424                { "set3", 0, PARAM_NOSTATIC, "set individual 3 coordinates", "p(f x,f y,f z)", PROCEDURE(p_set3), },
     
    3232                { "rotate", 0, PARAM_NOSTATIC, "rotate using Orient object", "p(oOrient)", PROCEDURE(p_rotate), },
    3333                { "revRotate", 0, PARAM_NOSTATIC, "reverse rotate using Orient object", "p(oOrient)", PROCEDURE(p_revrotate), },
    34                 { "get", 0, PARAM_NOSTATIC, "get one of coordinates", "p f(d index)", PROCEDURE(p_get), "this function makes the XYZ objects \"indexable\" (so you can use [] for accessing subsequent fields, like in Vector)", },
     34                { "get", 0, PARAM_READONLY | PARAM_NOSTATIC, "get one of coordinates", "p f(d index)", PROCEDURE(p_get), "this function makes the XYZ objects \"indexable\" (so you can use [] for accessing subsequent fields, like in Vector)", },
    3535                { 0, 0, 0, },
    3636        };
  • cpp/frams/vm/classes/collectionobj.cpp

    r1130 r1158  
    3131        { "size", 0, PARAM_READONLY | PARAM_NOSTATIC, "Element count", "d", GETONLY(size), },
    3232        { "remove", 0, PARAM_NOSTATIC, "Remove at position", "p(d position)", PROCEDURE(p_remove), },
    33         { "get", 0, PARAM_NOSTATIC, "Get value at position", "p x(d position)", PROCEDURE(p_get), "object[position] can be always used instead of object.get(position)" },
     33        { "get", 0, PARAM_READONLY | PARAM_NOSTATIC, "Get value at position", "p x(d position)", PROCEDURE(p_get), "object[position] can be always used instead of object.get(position)" },
    3434        { "set", 0, PARAM_NOSTATIC, "Set value at position", "p(d position,x value)", PROCEDURE(p_set), "object[position]=value can be always used instead of object.set(position,value)" },
    3535        { "insert", 0, PARAM_NOSTATIC, "Insert value at position", "p(d position,x value)", PROCEDURE(p_insert), },
    3636        { "add", 0, PARAM_NOSTATIC, "Append at the end", "p(x value)", PROCEDURE(p_add), },
    37         { "find", 0, PARAM_NOSTATIC, "Find", "p d(x value)", PROCEDURE(p_find), "returns the element index or -1 if not found" },
     37        { "find", 0, PARAM_READONLY | PARAM_NOSTATIC, "Find", "p d(x value)", PROCEDURE(p_find), "returns the element index or -1 if not found" },
    3838        { "avg", 0, PARAM_READONLY | PARAM_NOSTATIC, "Average", "x", GETONLY(avg) },
    3939        { "stdev", 0, PARAM_READONLY | PARAM_NOSTATIC, "Standard deviation", "x", GETONLY(stdev), "=sqrt(sum((element[i]-avg)^2)/(size-1)) which is estimated population std.dev. from sample std.dev." },
     
    4242        { "sort", 0, PARAM_NOSTATIC, "Sort elements (in place)", "p(oFunctionReference comparator)", PROCEDURE(p_sort), "comparator can be null, giving the \"natural\" sorting order (depending on element type), otherwise it must be a function reference obtained from the 'function' operator.\n\nExample:\nfunction compareLastDigit(a,b) {return (a%10)<(b%10);}\nvar v=[16,23,35,42,54,61];\nv.sort(function compareLastDigit);" },
    4343        { "iterator", 0, PARAM_NOSTATIC | PARAM_READONLY, "Iterator", "o", GETONLY(iterator), },
    44         { "clone", 0, PARAM_NOSTATIC, "Create a clone", "p oVector()", PROCEDURE(p_clone), "The resulting clone is a shallow copy (contains the same object references as the original). A deep copy can be obtained through serialization: String.deserialize(String.serialize(object));" },
     44        { "clone", 0, PARAM_READONLY | PARAM_NOSTATIC, "Create a clone", "p oVector()", PROCEDURE(p_clone), "The resulting clone is a shallow copy (contains the same object references as the original). A deep copy can be obtained through serialization: String.deserialize(String.serialize(object));" },
    4545        { 0, 0, 0, },
    4646};
     
    7272        { "size", 0, PARAM_NOSTATIC | PARAM_READONLY, "Element count", "d", GETONLY(size), },
    7373        { "remove", 0, PARAM_NOSTATIC, "Remove", "p(x key)", PROCEDURE(p_remove), "Removes the named or indexed element (depending on the argument type: string or int)." },
    74         { "get", 0, PARAM_NOSTATIC, "Get element", "p x(x key)", PROCEDURE(p_get), "Retrieves the named or indexed element (depending on the argument type: string or int). Accessing nonexistent keys is an error (use hasKey() if necessary).\nobject.get(key) can be shortened to object[key]." },
    75         { "getKey", 0, PARAM_NOSTATIC, "Get a key", "p s(d index)", PROCEDURE(p_getKey), "Returns the key of the indexed element (0 <= index < size)." },
    76         { "hasKey", 0, PARAM_NOSTATIC, "Check if key exists", "p d(s key)", PROCEDURE(p_hasKey), "Returns 1 (interpreted as true) if dictionary contains the supplied key, or 0 (false) otherwise.\nExample:\n   if (obj.hasKey(\"a\"))\n      x = obj->a;" },
     74        { "get", 0, PARAM_READONLY | PARAM_NOSTATIC, "Get element", "p x(x key)", PROCEDURE(p_get), "Retrieves the named or indexed element (depending on the argument type: string or int). Accessing nonexistent keys is an error (use hasKey() if necessary).\nobject.get(key) can be shortened to object[key]." },
     75        { "getKey", 0, PARAM_READONLY | PARAM_NOSTATIC, "Get a key", "p s(d index)", PROCEDURE(p_getKey), "Returns the key of the indexed element (0 <= index < size)." },
     76        { "hasKey", 0, PARAM_READONLY | PARAM_NOSTATIC, "Check if key exists", "p d(s key)", PROCEDURE(p_hasKey), "Returns 1 (interpreted as true) if dictionary contains the supplied key, or 0 (false) otherwise.\nExample:\n   if (obj.hasKey(\"a\"))\n      x = obj->a;" },
    7777        { "set", 0, PARAM_NOSTATIC, "Set element", "p x(x key,x value)", PROCEDURE(p_set), "Set element value for the specified key or index (depending on the argument type: string or int).\n"
    7878        "Returns the value previously associated with the given key (or index).\n"
     
    8181        "  var old_value=object.set(\"key\",new_value); //'old_value' gets the value previously associated with \"key\"\n"
    8282        "  var x=object[\"key\"]=new_value; //'x' becomes 'new_value', consistently with the semantics of the assignment operator. The value previously associated with \"key\" is lost." },
    83         { "find", 0, PARAM_NOSTATIC, "Find", "p x(x value)", PROCEDURE(p_find), "Returns the element key or null if not found." },
     83        { "find", 0, PARAM_READONLY | PARAM_NOSTATIC, "Find", "p x(x value)", PROCEDURE(p_find), "Returns the element key or null if not found." },
    8484        { "new", 0, 0, "Create a Dictionary", "p oDictionary()", STATICPROCEDURE(p_new), "Empty directory can be also created using the {} expression." },
    8585        { "toString", 0, PARAM_READONLY | PARAM_NOSTATIC, "Textual form", "s", GETONLY(toString), },
    86         { "clone", 0, PARAM_NOSTATIC, "Create a clone", "p oDictionary()", PROCEDURE(p_clone), "The resulting clone is a shallow copy (contains the same object references as the original). A deep copy can be obtained through serialization: String.deserialize(String.serialize(object));" },
     86        { "clone", 0, PARAM_READONLY | PARAM_NOSTATIC, "Create a clone", "p oDictionary()", PROCEDURE(p_clone), "The resulting clone is a shallow copy (contains the same object references as the original). A deep copy can be obtained through serialization: String.deserialize(String.serialize(object));" },
    8787        { "assign", 0, PARAM_NOSTATIC, "Assign from another object", "p(x)", PROCEDURE(p_assign), "Replaces current dictionary with dictionary contents from another object." },
    8888        { "iterator", 0, PARAM_NOSTATIC | PARAM_READONLY, "Iterator", "o", GETONLY(iterator), },
     
    9999
    100100VectorObject::VectorObject(Pt3D &pt)
    101         :readonly(0), owndata(1)
     101        :owndata(1)
    102102{
    103103        set_or_insert(0, ExtValue(pt.x), false);
     
    119119void VectorObject::p_remove(PARAMPROCARGS)
    120120{
    121         if (readonly) return;
    122121        int i = args->getInt();
    123122        if (!listIndexCheck(&data, i, "VectorObject", "remove")) return;
     
    270269        VMachine *vm;
    271270        VMVEComparator(VMachine::JumpTargetObject *_jto) :jto(_jto), vm(jto->vm) {}
    272 #ifdef QSORT_R_USING_QSORT_S
     271#ifdef QSORT_R_THIS_FIRST
    273272        static int compare(void* _this, const void *a, const void *b);
    274273        bool operator()(const ExtValue *a, const ExtValue *b) { return compare(this,&a,&b) == ExtValue::ResultLower; }
     
    279278};
    280279
    281 #ifdef QSORT_R_USING_QSORT_S
     280#ifdef QSORT_R_THIS_FIRST
    282281int VMVEComparator::compare(void* _this, const void *a, const void *b)
    283282#else
     
    324323                std::sort(first, first + data.size(), cmp); //no qsort_r() or equivalent on Android (yet)
    325324#else
    326                 qsort_r(first, data.size(), sizeof(ExtValue*), cmp.compare, &cmp);
     325                CALL_QSORT_R(first, data.size(), sizeof(ExtValue*), cmp.compare, &cmp);
    327326#endif
    328327        }
  • cpp/frams/vm/classes/collectionobj.h

    r929 r1158  
    1616public:
    1717        SList data;
    18         unsigned int readonly : 1, owndata : 1;
     18        unsigned int owndata : 1;
    1919        void clear();
    2020        ExtValue *get(int i) { return (ExtValue*)data.get(i); }
     
    2424        static Param par;
    2525        VectorObject(Pt3D& pt);
    26         VectorObject() :readonly(0), owndata(1) {}
     26        VectorObject() :owndata(1) {}
    2727        ~VectorObject() { clear(); }
    2828        static Param& getStaticParam() { return par; }
    2929#define STATRICKCLASS VectorObject
    30         PARAMPROCDEF(p_clear) { if (readonly) return; clear(); }
     30        PARAMPROCDEF(p_clear) { clear(); }
    3131        PARAMGETDEF(size) { arg1->setInt(data.size()); }
    3232        PARAMGETDEF(avg);
     
    3636        PARAMPROCDEF(p_get);
    3737        PARAMPROCDEF(p_find);
    38         PARAMPROCDEF(p_set) { if (!readonly) set_or_insert(arg1[1].getInt(), arg1[0], false); }
    39         PARAMPROCDEF(p_add) { if (readonly) return; /*ExtValue tmp; get_toString(&tmp); printf("%s += %s",(const char*)tmp.getString(),(const char*)arg1[0].getString());*/ data += new ExtValue(arg1[0]); /*get_toString(&tmp); printf(" -> %s\n",(const char*)tmp.getString());*/ arg2->setInt(data.size() - 1); }
    40         PARAMPROCDEF(p_insert) { if (!readonly) set_or_insert(arg1[1].getInt(), arg1[0], true); }
     38        PARAMPROCDEF(p_set) { set_or_insert(arg1[1].getInt(), arg1[0], false); }
     39        PARAMPROCDEF(p_add) { data += new ExtValue(arg1[0]); arg2->setInt(data.size() - 1); }
     40        PARAMPROCDEF(p_insert) { set_or_insert(arg1[1].getInt(), arg1[0], true); }
    4141        PARAMGETDEF(toString);
    4242        PARAMPROCDEF(p_sort);
  • cpp/frams/vm/classes/genoobj.cpp

    r999 r1158  
    2323        "-1 = validity is not known. This is a transient state. The value of \"is_valid\" will never be -1 when read. It is safe to treat is_valid as boolean in statements like \"if (g.is_valid) ...\". Setting \"is_valid=-1\" will make it 0 or 1 again. This third state (-1) is only needed for loading Genotype objects from files where the \"is_valid\" field might not be present."
    2424        },
    25         { "getConverted", 0, PARAM_NOSTATIC, "Get converted genotype", "p oGeno(s format)", PROCEDURE(p_getconvert), },
    26         { "getConvertedWithCheckpoints", 0, PARAM_NOSTATIC, "Get converted genotype", "p oGeno(s format)", PROCEDURE(p_getconvert_ch), "See also Model.newWithCheckpoints()" },
     25        { "getConverted", 0, PARAM_READONLY | PARAM_NOSTATIC, "Get converted genotype", "p oGeno(s format)", PROCEDURE(p_getconvert), },
     26        { "getConvertedWithCheckpoints", 0, PARAM_READONLY | PARAM_NOSTATIC, "Get converted genotype", "p oGeno(s format)", PROCEDURE(p_getconvert_ch), "See also Model.newWithCheckpoints()" },
    2727        { "f0genotype", 0, PARAM_NOSTATIC | PARAM_READONLY, "f0 genotype", "s 1", GETONLY(f0genotype), "converted to f0 genotype", },
    2828        { "new", 0, 0, "create new empty object", "p oGeno()", PROCEDURE(p_new), },
  • framspy/deterministic.sim

    r1149 r1158  
    1010
    1111sim_params:
     12# no need to evaluate a creature many times:
     13evalcount:1
    1214# always central location in the world:
    1315placement:1
    14 # no need to evaluate many times:
    15 evalcount:1
    1616# no random initialization of state in neurons:
    1717randinit:0.0
  • framspy/frams-test-props.py

    r1151 r1158  
     1"""An example of iterating through the properties of an ExtValue object and printing their characteristics."""
     2
    13import frams
    24import sys
     
    46frams.init(*(sys.argv[1:]))
    57
    6 def printSingleProperty(v,p):
    7         print('  %s "%s" type="%s" flags=%d group=%d help="%s"' % (v._propId(p),v._propName(p),v._propType(p),v._propFlags(p),v._propGroup(p),v._propHelp(p)))
     8
     9def printSingleProperty(v, p):
     10        print(' * %s "%s" type="%s" flags=%d group=%d help="%s"' % (v._propId(p), v._propName(p), v._propType(p), v._propFlags(p), v._propGroup(p), v._propHelp(p)))
    811
    912
    1013def printFramsProperties(v):
    11         N=v._propCount()
    12         G=v._groupCount()
    13         if G<2:
    14                
    15                 #no groups, simply iterate all props
    16                
    17                 print("'%s' has %d properties" % (v._class(),v._propCount()))
     14        N = v._propCount()
     15        G = v._groupCount()
     16        print("======================= '%s' has %d properties in %d group(s). =======================" % (v._class(), N, G))
     17        if G < 2:
     18                # No groups, simply iterate all properties
    1819                for p in range(v._propCount()):
    19                         printSingleProperty(v,p)
    20                
     20                        printSingleProperty(v, p)
    2121        else:
    22                
    23                 #iterate through groups and iterate all props in a group.
    24                 #why the distinction?
    25                 #first, just to show there are two ways. there is always at least one
    26                 #group so you can always get all props by iterating the group.
    27                 #second, groups actually do not exist as collections. iterating in
    28                 #groups works by checking all properties on each iteration and
    29                 #testing which one is the m-th property of the group.
    30                 #these inefficient _memberCount() and _groupMember() are provided
    31                 #for the sake of completeness but don't use them without good reason ;-)
    32                
    33                 print("'%s' has %d properties in %d group(s)" % (v._class(),v._propCount(),v._groupCount()))
     22                # Iterate through groups and iterate all props in a group.
     23                # Why the distinction?
     24                # First, just to show there are two ways. There is always at least one
     25                # group so you can always get all properties by iterating the group.
     26                # Second, groups actually do not exist as collections. Iterating in
     27                # groups works by checking all properties on each iteration and
     28                # testing which one is the m-th property of the group!
     29                # So these inefficient _memberCount() and _groupMember() are provided
     30                # for the sake of completeness, but don't use them without a good reason ;-)
    3431                for g in range(G):
    35                         print('\n=========== Group #%d: %s ==========' % (g,v._groupName(g)))
     32                        print('\n------------------- Group #%d: %s -------------------' % (g, v._groupName(g)))
    3633                        for m in range(v._memberCount(g)):
    37                                 p=v._groupMember(g,m)
    38                                 printSingleProperty(v,p)
    39                         print('========================\n')
    40 
    41 
     34                                p = v._groupMember(g, m)
     35                                printSingleProperty(v, p)
     36        print('\n\n')
    4237
    4338
    4439printFramsProperties(frams.World)
    45                
    46 printFramsProperties(frams.GenePools[0].add('X'))
     40
     41printFramsProperties(frams.GenePools[0].add('X'))  # add('X') returns a Genotype object
  • framspy/run-evolalg-examples.cmd

    r1149 r1158  
    77
    88
    9 rem simple one-criterion evolution
     9
     10rem simple one-criterion evolution from minimalistic example source (examples.standard)
    1011python -m evolalg.examples.standard          -path %DIR_WITH_FRAMS_LIBRARY%   -opt numneurons
    1112
    1213
    13 rem "chaining" .sim files, subsequent files overwrite selected parameters
     14rem as above but "chaining" .sim files, subsequent files overwrite selected parameters
    1415python -m evolalg.examples.standard          -path %DIR_WITH_FRAMS_LIBRARY%   -sim eval-allcriteria.sim;deterministic.sim;sample-period-longest.sim    -opt velocity
    1516
    1617
    17 rem hard limit on the number of parts
     18rem simple one-criterion evolution but more options available in examples.niching_novelty, here: hard limit on the number of parts and debugging messages
    1819python -m evolalg.examples.niching_novelty   -path %DIR_WITH_FRAMS_LIBRARY%   -opt velocity   -max_numparts 6   -debug
    1920
  • framspy/sample-period-longest.sim

    r1149 r1158  
    1 # Extremely high "performance sampling period" (likely longer than lifespan) in the first population
    2 # to measure distance and velocity rectilinearly. Such a long period results in two sampling events: at birth and at death.
     1# Extremely high "performance sampling period" in the first population to measure distance and velocity rectilinearly.
     2# Such a long period (likely longer than lifespan) results in two sampling events: at birth and at death.
    33#
    44# Before loading this file, load base settings, e.g. "eval-allcriteria.sim".
Note: See TracChangeset for help on using the changeset viewer.