Changeset 932 for cpp/frams


Ignore:
Timestamp:
05/28/20 18:00:45 (4 years ago)
Author:
Maciej Komosinski
Message:

Neuron classes now have a property (a bit field) that says whether each neuron class supports model shape BALL_AND_STICK, SOLIDS, or both

Location:
cpp/frams
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • cpp/frams/config/f0-SDK.def

    r920 r932  
    106106PROP(Vstyle,2,0,vis_style,s,0,0,neuro,vis_style)
    107107PROP(getInputCount,0,1+2,`input count',d,,,,inputCount,GETONLY)
    108 PROP(getInputNeuroDef,0,1+2,`get input neuron',p oNeuroDef(d),,,,p_getInputNeuroDef,PROCEDURE)
    109 PROP(getInputNeuroIndex,0,1+2,`get input neuron index',p d(d),,,,p_getInputNeuroIndex,PROCEDURE)
    110 PROP(getInputWeight,0,1+2,`get input weight',p f(d),,,,p_getInputWeight,PROCEDURE)
     108PROP(getInputNeuroDef,0,0,`get input neuron',p oNeuroDef(d),,,,p_getInputNeuroDef,PROCEDURE)
     109PROP(getInputNeuroIndex,0,0,`get input neuron index',p d(d),,,,p_getInputNeuroIndex,PROCEDURE)
     110PROP(getInputWeight,0,0,`get input weight',p f(d),,,,p_getInputWeight,PROCEDURE)
    111111PROP(classObject,0,1+2,`neuron class',oNeuroClass,,,,classObject,GETONLY)
    112112ENDCLASS
     
    158158
    159159NEUROCLASS(BendMuscle,|,Bend muscle,,1,0,2)
     160SHAPETYPE(BallAndStickShapeType)
    160161VISUALHINTS(DontShowClass+EffectorClass+V1BendMuscle+AtFirstPart)
    161162SYMBOL(`6,5,25,40,35,40,45,50,35,60,25,60,25,40,4,65,85,65,50,75,50,75,85,65,85,3,65,56,49,29,57,24,72,50,4,68,53,70,53,70,55,68,55,68,53,5,50,21,60,15,70,14,79,15,87,20,81,10,1,86,20,77,21')
     
    165166
    166167NEUROCLASS(RotMuscle,@,Rotation muscle,,1,0,2)
     168SHAPETYPE(BallAndStickShapeType)
    167169VISUALHINTS(DontShowClass+EffectorClass+V1RotMuscle+AtFirstPart)
    168170SYMBOL(`5,5,25,40,35,40,45,50,35,60,25,60,25,40,4,65,85,65,50,75,50,75,85,65,85,1,69,10,77,17,10,59,15,57,17,57,22,60,26,69,27,78,26,82,21,82,16,79,12,69,10,80,6,3,65,50,65,20,75,20,75,50')
     
    171173
    172174NEUROCLASS(SolidMuscle,M,Muscle,,1,0,2)
     175SHAPETYPE(SolidsShapeType)
    173176VISUALHINTS(EffectorClass+AtFirstPart+SolidMuscleFlag)
    174177SYMBOL(`6,5,25,40,35,40,45,50,35,60,25,60,25,40,4,65,85,65,50,75,50,75,85,65,85,3,65,56,49,29,57,24,72,50,4,68,53,70,53,70,55,68,55,68,53,5,50,21,60,15,70,14,79,15,87,20,81,10,1,86,20,77,21')
     
    190193
    191194NEUROCLASS(Sticky,Sti,Sticky [EXPERIMENTAL!],,1,0,1)
     195SHAPETYPE(BallAndStickShapeType)
    192196VISUALHINTS(EffectorClass)
    193197ENDNEUROCLASS
    194198
    195199NEUROCLASS(LinearMuscle,LMu,Linear muscle [EXPERIMENTAL!],,1,0,2)
    196 VISUALHINTS(EffectorClass)
     200SHAPETYPE(BallAndStickShapeType)
     201VISUALHINTS(EffectorClass+LinearMuscleFlag)
    197202NEUROPROP(p,0,0,power,f,0.01,1.0,1.0,power)
    198203ENDNEUROCLASS
  • cpp/frams/config/f0.def

    r920 r932  
    158158
    159159NEUROCLASS(BendMuscle,|,Bend muscle,,1,0,2)
     160SHAPETYPE(BallAndStickShapeType)
    160161VISUALHINTS(DontShowClass+EffectorClass+V1BendMuscle+AtFirstPart)
    161162SYMBOL(`6,5,25,40,35,40,45,50,35,60,25,60,25,40,4,65,85,65,50,75,50,75,85,65,85,3,65,56,49,29,57,24,72,50,4,68,53,70,53,70,55,68,55,68,53,5,50,21,60,15,70,14,79,15,87,20,81,10,1,86,20,77,21')
     
    165166
    166167NEUROCLASS(RotMuscle,@,Rotation muscle,,1,0,2)
     168SHAPETYPE(BallAndStickShapeType)
    167169VISUALHINTS(DontShowClass+EffectorClass+V1RotMuscle+AtFirstPart)
    168170SYMBOL(`5,5,25,40,35,40,45,50,35,60,25,60,25,40,4,65,85,65,50,75,50,75,85,65,85,1,69,10,77,17,10,59,15,57,17,57,22,60,26,69,27,78,26,82,21,82,16,79,12,69,10,80,6,3,65,50,65,20,75,20,75,50')
     
    171173
    172174NEUROCLASS(SolidMuscle,M,Muscle,,1,0,2)
     175SHAPETYPE(SolidsShapeType)
    173176VISUALHINTS(EffectorClass+AtFirstPart+SolidMuscleFlag)
    174177SYMBOL(`6,5,25,40,35,40,45,50,35,60,25,60,25,40,4,65,85,65,50,75,50,75,85,65,85,3,65,56,49,29,57,24,72,50,4,68,53,70,53,70,55,68,55,68,53,5,50,21,60,15,70,14,79,15,87,20,81,10,1,86,20,77,21')
     
    209212
    210213NEUROCLASS(Sticky,Sti,Sticky [EXPERIMENTAL!],,1,0,1)
     214SHAPETYPE(BallAndStickShapeType)
    211215VISUALHINTS(EffectorClass)
    212216ENDNEUROCLASS
    213217
    214218NEUROCLASS(LinearMuscle,LMu,Linear muscle [EXPERIMENTAL!],,1,0,2)
     219SHAPETYPE(BallAndStickShapeType)
    215220VISUALHINTS(EffectorClass+LinearMuscleFlag)
    216221NEUROPROP(p,0,0,power,f,0.01,1.0,1.0,power)
  • cpp/frams/model/defassign-f0-SDK.h

    r915 r932  
    2525vcolor.z=1.0;
    2626}
     27
    2728
    2829
     
    119120
    120121
     122
    121123void Neuro::defassign()
    122124{
     
    126128vis_style="neuro";
    127129}
     130
    128131
    129132
     
    184187
    185188
     189
  • cpp/frams/model/f0-SDK-classes.h

    r920 r932  
    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-2015  Maciej Komosinski and Szymon Ulatowski.
    33// See LICENSE.txt for details.
    44
     
    172172 {"Vstyle",2,0,"vis_style","s 0 0 neuro",FIELD(vis_style),},
    173173 {"getInputCount",0,1+2,"input count","d",GETONLY(inputCount),},
    174  {"getInputNeuroDef",0,1+2,"get input neuron","p oNeuroDef(d)",PROCEDURE(p_getInputNeuroDef),},
    175  {"getInputNeuroIndex",0,1+2,"get input neuron index","p d(d)",PROCEDURE(p_getInputNeuroIndex),},
    176  {"getInputWeight",0,1+2,"get input weight","p f(d)",PROCEDURE(p_getInputWeight),},
     174 {"getInputNeuroDef",0,0,"get input neuron","p oNeuroDef(d)",PROCEDURE(p_getInputNeuroDef),},
     175 {"getInputNeuroIndex",0,0,"get input neuron index","p d(d)",PROCEDURE(p_getInputNeuroIndex),},
     176 {"getInputWeight",0,0,"get input weight","p f(d)",PROCEDURE(p_getInputWeight),},
    177177 {"classObject",0,1+2,"neuron class","oNeuroClass",GETONLY(classObject),},
    178178 {0,0,0,}
  • cpp/frams/model/model.h

    r896 r932  
    11// This file is a part of Framsticks SDK.  http://www.framsticks.com/
    2 // Copyright (C) 1999-2019  Maciej Komosinski and Szymon Ulatowski.
     2// Copyright (C) 1999-2020  Maciej Komosinski and Szymon Ulatowski.
    33// See LICENSE.txt for details.
    44
     
    9393
    9494public:
    95         enum ShapeType { SHAPE_UNKNOWN, SHAPE_ILLEGAL, SHAPE_BALL_AND_STICK, SHAPE_SOLIDS };
     95        enum ShapeType { SHAPE_BALL_AND_STICK = 0, SHAPE_SOLIDS = 1, SHAPE_UNKNOWN, SHAPE_ILLEGAL };
    9696        /// used in internalCheck()
    9797        enum CheckType {
  • cpp/frams/model/modelparts.cpp

    r926 r932  
    11// This file is a part of Framsticks SDK.  http://www.framsticks.com/
    2 // Copyright (C) 1999-2019  Maciej Komosinski and Szymon Ulatowski.
     2// Copyright (C) 1999-2020  Maciej Komosinski and Szymon Ulatowski.
    33// See LICENSE.txt for details.
    44
     
    9898NeuroClass::NeuroClass(ParamEntry *_props, SString _description,
    9999        int _prefinputs, int _prefoutput, int _preflocation,
    100         int *_vectordata, bool own_vd, int vhints)
     100        int *_vectordata, bool own_vd, int vhints, int sup_shapes)
    101101        :ownedvectordata(own_vd),
    102102        name(_props->name), longname(_props->id), description(_description),
     
    105105        prefoutput(_prefoutput),
    106106        preflocation(_preflocation),
     107        supported_shape_types(sup_shapes),
    107108        vectordata(_vectordata),
    108109        visualhints(vhints), impl_count(0),/*impl(0),*/active(1), genactive(0)
  • cpp/frams/model/modelparts.h

    r920 r932  
    124124        class Pt3D d;           ///< position delta between parts
    125125        class Pt3D rot; ///< orientation delta between parts expressed as 3 angles
    126         enum Shape { SHAPE_BALL_AND_STICK = 0, ///<  old Framsticks compatible, creates a physical rod between parts (cylinder or cuboid), do not mix with part.shape>0
    127                      SHAPE_FIXED = 1, ///< merge parts into one physical entity
    128                      SHAPE_HINGE_X = 2, ///< hinge connection, revolving around X axis defined by hinge_pos and hinge_rot
    129                      SHAPE_HINGE_XY = 3 }; ///< double hinge connection, revolving around X and Y axes defined by hinge_pos and hinge_rot
     126        enum Shape {
     127                SHAPE_BALL_AND_STICK = 0, ///<  old Framsticks compatible, creates a physical rod between parts (cylinder or cuboid), do not mix with part.shape>0
     128                SHAPE_FIXED = 1, ///< merge parts into one physical entity
     129                SHAPE_HINGE_X = 2, ///< hinge connection, revolving around X axis defined by hinge_pos and hinge_rot
     130                SHAPE_HINGE_XY = 3 ///< double hinge connection, revolving around X and Y axes defined by hinge_pos and hinge_rot
     131        };
    130132        paInt shape;///< values of type Shape (paInt for integration with Param)
    131133        class Pt3D hinge_pos; ///< hinge position (relative to part1) for HINGE_X and HINGE_XY
     
    199201        paInt prefinputs, prefoutput;
    200202        paInt preflocation;
     203
     204        static constexpr int SUPPORTED_SHAPE_BALL_AND_STICK = 1;
     205        static constexpr int SUPPORTED_SHAPE_SOLIDS = 2;
     206        static constexpr int SUPPORTED_SHAPE_ALL = SUPPORTED_SHAPE_BALL_AND_STICK | SUPPORTED_SHAPE_SOLIDS;
     207        paInt supported_shape_types; //< bitfield of 'Model::shape' values: NeuroClass::SUPPORTED_SHAPE_xxx = 1 << Model::SHAPE_xxx
    201208        int *vectordata;
    202209        paInt visualhints;
     
    212219        NeuroClass();
    213220        NeuroClass(ParamEntry *_props, SString _description,
    214                 int _prefinputs, int _prefoutput, int _preflocation, int *_vectordata, bool own_vd = 1, int vhints = 0);
     221                int _prefinputs, int _prefoutput, int _preflocation, int *_vectordata, bool own_vd = 1, int vhints = 0, int sup_shapes = NeuroClass::SUPPORTED_SHAPE_ALL);
    215222        /** class name for use in Neuro::setClassName(), Neuro::setDetails() (former 'moredata' field),
    216223                eg. "N","-",G" */
     
    248255                }
    249256                */
     257        int getSupportedShapeTypes() { return (int)supported_shape_types; }
    250258        int *getSymbolGlyph()
    251259        {
  • cpp/frams/neuro/neurocls-f0-SDK-library.h

    r924 r932  
    1212
    1313
    14      
     14      
    1515static ParamEntry NI_StdNeuron_tab[]={
    1616{"Neuron",1, 4 ,"N",},
     
    2222 
    2323{0,0,0,},};
    24 addClass(new NeuroClass(NI_StdNeuron_tab,"Standard neuron",-1,1,0, NULL,false, 2));
    25 
    26      
     24addClass(new NeuroClass(NI_StdNeuron_tab,"Standard neuron",-1,1,0, NULL,false, 2, 3));
     25
     26      
    2727static ParamEntry NI_StdUNeuron_tab[]={
    2828{"Unipolar neuron [EXPERIMENTAL!]",1, 4 ,"Nu",},
     
    3333 
    3434{0,0,0,},};
    35 addClass(new NeuroClass(NI_StdUNeuron_tab,"Works like standard neuron (N) but the output value is scaled to 0...+1 instead of -1...+1.\nHaving 0 as one of the saturation states should help in \"gate circuits\", where input signal is passed through or blocked depending on the other singal.",-1,1,0, NULL,false, 0));
    36 
    37      static int Gyro_xy[]={83,8,7,100,50,90,50,90,40,70,40,80,50,70,60,90,60,90,50,12,43,24,48,24,48,19,38,19,38,24,43,24,43,54,48,54,48,64,43,69,38,64,38,54,43,54,5,63,69,58,74,48,79,38,79,28,74,23,69,1,43,79,43,74,1,23,69,26,66,1,63,69,60,66,1,55,76,53,73,1,31,75,33,72};   
     35addClass(new NeuroClass(NI_StdUNeuron_tab,"Works like standard neuron (N) but the output value is scaled to 0...+1 instead of -1...+1.\nHaving 0 as one of the saturation states should help in \"gate circuits\", where input signal is passed through or blocked depending on the other singal.",-1,1,0, NULL,false, 0, 3));
     36
     37      static int Gyro_xy[]={83,8,7,100,50,90,50,90,40,70,40,80,50,70,60,90,60,90,50,12,43,24,48,24,48,19,38,19,38,24,43,24,43,54,48,54,48,64,43,69,38,64,38,54,43,54,5,63,69,58,74,48,79,38,79,28,74,23,69,1,43,79,43,74,1,23,69,26,66,1,63,69,60,66,1,55,76,53,73,1,31,75,33,72};   
    3838static ParamEntry NI_Gyro_tab[]={
    3939{"Gyroscope",1, 0 ,"G",},
     
    4242 
    4343{0,0,0,},};
    44 addClass(new NeuroClass(NI_Gyro_tab,"Equilibrium sensor.\n0=the stick is horizontal\n+1/-1=the stick is vertical",0,1,2, Gyro_xy,false, 32));
    45 
    46      static int Touch_xy[]={43,2,7,100,50,90,50,90,40,70,40,80,50,70,60,90,60,90,50,11,75,50,65,50,60,55,55,45,50,55,45,45,40,50,35,50,30,45,25,50,30,55,35,50};   
     44addClass(new NeuroClass(NI_Gyro_tab,"Equilibrium sensor.\n0=the stick is horizontal\n+1/-1=the stick is vertical",0,1,2, Gyro_xy,false, 32, 3));
     45
     46      static int Touch_xy[]={43,2,7,100,50,90,50,90,40,70,40,80,50,70,60,90,60,90,50,11,75,50,65,50,60,55,55,45,50,55,45,45,40,50,35,50,30,45,25,50,30,55,35,50};   
    4747static ParamEntry NI_Touch_tab[]={
    4848{"Touch",1, 1 ,"T",},
     
    5252 
    5353{0,0,0,},};
    54 addClass(new NeuroClass(NI_Touch_tab,"Touch sensor.\n-1=no contact\n0=just touching\n>0=pressing, value depends on the force applied",0,1,1, Touch_xy,false, 32));
    55 
    56      static int Smell_xy[]={64,5,7,100,50,90,50,90,40,70,40,80,50,70,60,90,60,90,50,3,10,40,15,45,15,55,10,60,5,20,30,25,35,30,45,30,55,25,65,20,70,4,15,35,20,40,22,50,20,60,15,65,5,75,50,50,50,45,45,40,50,45,55,50,50};   
     54addClass(new NeuroClass(NI_Touch_tab,"Touch sensor.\n-1=no contact\n0=just touching\n>0=pressing, value depends on the force applied",0,1,1, Touch_xy,false, 32, 3));
     55
     56      static int Smell_xy[]={64,5,7,100,50,90,50,90,40,70,40,80,50,70,60,90,60,90,50,3,10,40,15,45,15,55,10,60,5,20,30,25,35,30,45,30,55,25,65,20,70,4,15,35,20,40,22,50,20,60,15,65,5,75,50,50,50,45,45,40,50,45,55,50,50};   
    5757static ParamEntry NI_Smell_tab[]={
    5858{"Smell",1, 0 ,"S",},
     
    6161 
    6262{0,0,0,},};
    63 addClass(new NeuroClass(NI_Smell_tab,"Smell sensor. Aggregated \"smell of energy\" experienced from all energy objects (creatures and food pieces).\nClose objects have bigger influence than the distant ones: for each energy source, its partial feeling is proportional to its energy/(distance^2)",0,1,1, Smell_xy,false, 32));
    64 
    65      static int Const_xy[]={29,4,4,26,27,26,73,73,73,73,27,26,27,1,73,50,100,50,1,56,68,46,68,2,41,47,51,32,51,68};   
     63addClass(new NeuroClass(NI_Smell_tab,"Smell sensor. Aggregated \"smell of energy\" experienced from all energy objects (creatures and food pieces).\nClose objects have bigger influence than the distant ones: for each energy source, its partial feeling is proportional to its energy/(distance^2)",0,1,1, Smell_xy,false, 32, 3));
     64
     65      static int Const_xy[]={29,4,4,26,27,26,73,73,73,73,27,26,27,1,73,50,100,50,1,56,68,46,68,2,41,47,51,32,51,68};   
    6666static ParamEntry NI_Const_tab[]={
    6767{"Constant",1, 0 ,"*",},
     
    7070 
    7171{0,0,0,},};
    72 addClass(new NeuroClass(NI_Const_tab,"Constant value",0,1,0, Const_xy,false, 1));
    73 
    74      static int BendMuscle_xy[]={63,6,5,25,40,35,40,45,50,35,60,25,60,25,40,4,65,85,65,50,75,50,75,85,65,85,3,65,56,49,29,57,24,72,50,4,68,53,70,53,70,55,68,55,68,53,5,50,21,60,15,70,14,79,15,87,20,81,10,1,86,20,77,21};   
     72addClass(new NeuroClass(NI_Const_tab,"Constant value",0,1,0, Const_xy,false, 1, 3));
     73
     74      static int BendMuscle_xy[]={63,6,5,25,40,35,40,45,50,35,60,25,60,25,40,4,65,85,65,50,75,50,75,85,65,85,3,65,56,49,29,57,24,72,50,4,68,53,70,53,70,55,68,55,68,53,5,50,21,60,15,70,14,79,15,87,20,81,10,1,86,20,77,21};   
    7575static ParamEntry NI_BendMuscle_tab[]={
    7676{"Bend muscle",1, 2 ,"|",},
    7777
    7878
     79
    7980{"p",0,0,"power","f 0.01 1.0 0.25",},
    8081{"r",0,0,"bending range","f 0.0 1.0 1.0",},
    8182 
    8283{0,0,0,},};
    83 addClass(new NeuroClass(NI_BendMuscle_tab,"",1,0,2, BendMuscle_xy,false, 2+16+64+4));
    84 
    85      static int RotMuscle_xy[]={62,5,5,25,40,35,40,45,50,35,60,25,60,25,40,4,65,85,65,50,75,50,75,85,65,85,1,69,10,77,17,10,59,15,57,17,57,22,60,26,69,27,78,26,82,21,82,16,79,12,69,10,80,6,3,65,50,65,20,75,20,75,50};   
     84addClass(new NeuroClass(NI_BendMuscle_tab,"",1,0,2, BendMuscle_xy,false, 2+16+64+4, 1));
     85
     86      static int RotMuscle_xy[]={62,5,5,25,40,35,40,45,50,35,60,25,60,25,40,4,65,85,65,50,75,50,75,85,65,85,1,69,10,77,17,10,59,15,57,17,57,22,60,26,69,27,78,26,82,21,82,16,79,12,69,10,80,6,3,65,50,65,20,75,20,75,50};   
    8687static ParamEntry NI_RotMuscle_tab[]={
    8788{"Rotation muscle",1, 1 ,"@",},
    8889
    8990
     91
    9092{"p",0,0,"power","f 0.01 1.0 1.0",},
    9193 
    9294{0,0,0,},};
    93 addClass(new NeuroClass(NI_RotMuscle_tab,"",1,0,2, RotMuscle_xy,false, 2+16+128+4));
    94 
    95      static int SolidMuscle_xy[]={63,6,5,25,40,35,40,45,50,35,60,25,60,25,40,4,65,85,65,50,75,50,75,85,65,85,3,65,56,49,29,57,24,72,50,4,68,53,70,53,70,55,68,55,68,53,5,50,21,60,15,70,14,79,15,87,20,81,10,1,86,20,77,21};   
     95addClass(new NeuroClass(NI_RotMuscle_tab,"",1,0,2, RotMuscle_xy,false, 2+16+128+4, 1));
     96
     97      static int SolidMuscle_xy[]={63,6,5,25,40,35,40,45,50,35,60,25,60,25,40,4,65,85,65,50,75,50,75,85,65,85,3,65,56,49,29,57,24,72,50,4,68,53,70,53,70,55,68,55,68,53,5,50,21,60,15,70,14,79,15,87,20,81,10,1,86,20,77,21};   
    9698static ParamEntry NI_SolidMuscle_tab[]={
    9799{"Muscle",1, 2 ,"M",},
    98100
    99101
     102
    100103{"p",0,0,"power","f 0.01 1.0 1.0",},
    101104{"a",0,0,"axis","d 0 1 0",},
    102105 
    103106{0,0,0,},};
    104 addClass(new NeuroClass(NI_SolidMuscle_tab,"",1,0,2, SolidMuscle_xy,false, 16+4+512));
    105 
    106      static int Diff_xy[]={24,3,3,25,0,25,100,75,50,25,0,1,75,50,100,50,3,44,42,51,57,36,57,44,42};   
     107addClass(new NeuroClass(NI_SolidMuscle_tab,"",1,0,2, SolidMuscle_xy,false, 16+4+512, 2));
     108
     109      static int Diff_xy[]={24,3,3,25,0,25,100,75,50,25,0,1,75,50,100,50,3,44,42,51,57,36,57,44,42};   
    107110static ParamEntry NI_Diff_tab[]={
    108111{"Differentiate",1, 0 ,"D",},
     
    110113 
    111114{0,0,0,},};
    112 addClass(new NeuroClass(NI_Diff_tab,"Calculate the difference between the current and previous input value. Multiple inputs are aggregated with respect to their weights",-1,1,0, Diff_xy,false, 0));
    113 
    114      static int FuzzyNeuro_xy[]={44,5,2,30,65,37,37,44,65,3,37,65,44,37,51,37,58,65,2,51,65,58,37,65,65,6,100,50,70,50,70,25,25,10,25,90,70,75,70,50,1,70,65,25,65};   
     115addClass(new NeuroClass(NI_Diff_tab,"Calculate the difference between the current and previous input value. Multiple inputs are aggregated with respect to their weights",-1,1,0, Diff_xy,false, 0, 3));
     116
     117      static int FuzzyNeuro_xy[]={44,5,2,30,65,37,37,44,65,3,37,65,44,37,51,37,58,65,2,51,65,58,37,65,65,6,100,50,70,50,70,25,25,10,25,90,70,75,70,50,1,70,65,25,65};   
    115118static ParamEntry NI_FuzzyNeuro_tab[]={
    116119{"Fuzzy system [EXPERIMENTAL!]",1, 4 ,"Fuzzy",},
     
    122125 
    123126{0,0,0,},};
    124 addClass(new NeuroClass(NI_FuzzyNeuro_tab,"Refer to publications to learn more about this neuron.",-1,1,0, FuzzyNeuro_xy,false, 0));
    125 
    126      
     127addClass(new NeuroClass(NI_FuzzyNeuro_tab,"Refer to publications to learn more about this neuron.",-1,1,0, FuzzyNeuro_xy,false, 0, 3));
     128
     129      
    127130static ParamEntry NI_Sticky_tab[]={
    128131{"Sticky [EXPERIMENTAL!]",1, 0 ,"Sti",},
    129132
    130  
    131 {0,0,0,},};
    132 addClass(new NeuroClass(NI_Sticky_tab,"",1,0,1, NULL,false, 16));
    133 
    134      
     133
     134 
     135{0,0,0,},};
     136addClass(new NeuroClass(NI_Sticky_tab,"",1,0,1, NULL,false, 16, 1));
     137
     138     
    135139static ParamEntry NI_LinearMuscle_tab[]={
    136140{"Linear muscle [EXPERIMENTAL!]",1, 1 ,"LMu",},
    137141
     142
    138143{"p",0,0,"power","f 0.01 1.0 1.0",},
    139144 
    140145{0,0,0,},};
    141 addClass(new NeuroClass(NI_LinearMuscle_tab,"",1,0,2, NULL,false, 16));
    142 
    143      
     146addClass(new NeuroClass(NI_LinearMuscle_tab,"",1,0,2, NULL,false, 16+256, 1));
     147
     148      
    144149static ParamEntry NI_WaterDetect_tab[]={
    145150{"Water detector",1, 0 ,"Water",},
     
    147152 
    148153{0,0,0,},};
    149 addClass(new NeuroClass(NI_WaterDetect_tab,"Output signal:\n0=on or above water surface\n1=under water (deeper than 1)\n0..1=in the transient area just below water surface",0,1,1, NULL,false, 32));
    150 
    151      
     154addClass(new NeuroClass(NI_WaterDetect_tab,"Output signal:\n0=on or above water surface\n1=under water (deeper than 1)\n0..1=in the transient area just below water surface",0,1,1, NULL,false, 32, 3));
     155
     156      
    152157static ParamEntry NI_Energy_tab[]={
    153158{"Energy level",1, 0 ,"Energy",},
     
    155160 
    156161{0,0,0,},};
    157 addClass(new NeuroClass(NI_Energy_tab,"The current energy level divided by the initial energy level.\nUsually falls from initial 1.0 down to 0.0 and then the creature dies. It can rise above 1.0 if enough food is ingested",0,1,0, NULL,false, 32));
    158 
    159      static int Channelize_xy[]={57,10,4,25,0,25,100,75,70,75,30,25,0,1,75,50,100,50,1,70,50,55,50,1,30,80,55,50,1,30,20,55,50,1,30,35,55,50,1,30,45,55,50,1,30,55,55,50,1,61,53,65,47,1,30,65,55,50};   
     162addClass(new NeuroClass(NI_Energy_tab,"The current energy level divided by the initial energy level.\nUsually falls from initial 1.0 down to 0.0 and then the creature dies. It can rise above 1.0 if enough food is ingested",0,1,0, NULL,false, 32, 3));
     163
     164      static int Channelize_xy[]={57,10,4,25,0,25,100,75,70,75,30,25,0,1,75,50,100,50,1,70,50,55,50,1,30,80,55,50,1,30,20,55,50,1,30,35,55,50,1,30,45,55,50,1,30,55,55,50,1,61,53,65,47,1,30,65,55,50};   
    160165static ParamEntry NI_Channelize_tab[]={
    161166{"Channelize",1, 0 ,"Ch",},
     
    163168 
    164169{0,0,0,},};
    165 addClass(new NeuroClass(NI_Channelize_tab,"Combines all input signals into a single multichannel output; Note: ChSel and ChMux are the only neurons which support multiple channels. Other neurons discard everything except the first channel.",-1,1,0, Channelize_xy,false, 0));
    166 
    167      static int ChMux_xy[]={52,7,4,25,0,25,100,75,70,75,30,25,0,1,75,50,100,50,1,70,50,55,50,3,50,55,55,50,50,45,50,55,3,30,67,45,67,45,50,50,50,1,35,70,39,64,2,30,33,53,33,53,48};   
     170addClass(new NeuroClass(NI_Channelize_tab,"Combines all input signals into a single multichannel output; Note: ChSel and ChMux are the only neurons which support multiple channels. Other neurons discard everything except the first channel.",-1,1,0, Channelize_xy,false, 0, 3));
     171
     172      static int ChMux_xy[]={52,7,4,25,0,25,100,75,70,75,30,25,0,1,75,50,100,50,1,70,50,55,50,3,50,55,55,50,50,45,50,55,3,30,67,45,67,45,50,50,50,1,35,70,39,64,2,30,33,53,33,53,48};   
    168173static ParamEntry NI_ChMux_tab[]={
    169174{"Channel multiplexer",1, 0 ,"ChMux",},
     
    171176 
    172177{0,0,0,},};
    173 addClass(new NeuroClass(NI_ChMux_tab,"Outputs the selected channel from the second (multichannel) input. The first input is used as the selector value (-1=select first channel, .., 1=last channel)",2,1,0, ChMux_xy,false, 0));
    174 
    175      static int ChSel_xy[]={41,6,4,25,0,25,100,75,70,75,30,25,0,1,75,50,100,50,1,70,50,55,50,3,50,55,55,50,50,45,50,55,1,30,50,50,50,1,35,53,39,47};   
     178addClass(new NeuroClass(NI_ChMux_tab,"Outputs the selected channel from the second (multichannel) input. The first input is used as the selector value (-1=select first channel, .., 1=last channel)",2,1,0, ChMux_xy,false, 0, 3));
     179
     180      static int ChSel_xy[]={41,6,4,25,0,25,100,75,70,75,30,25,0,1,75,50,100,50,1,70,50,55,50,3,50,55,55,50,50,45,50,55,1,30,50,50,50,1,35,53,39,47};   
    176181static ParamEntry NI_ChSel_tab[]={
    177182{"Channel selector",1, 1 ,"ChSel",},
     
    180185 
    181186{0,0,0,},};
    182 addClass(new NeuroClass(NI_ChSel_tab,"Outputs a single channel (selected by the \"ch\" parameter) from multichannel input",1,1,0, ChSel_xy,false, 0));
    183 
    184      
     187addClass(new NeuroClass(NI_ChSel_tab,"Outputs a single channel (selected by the \"ch\" parameter) from multichannel input",1,1,0, ChSel_xy,false, 0, 3));
     188
     189      
    185190static ParamEntry NI_Random_tab[]={
    186191{"Random noise",1, 0 ,"Rnd",},
    187192 
    188193{0,0,0,},};
    189 addClass(new NeuroClass(NI_Random_tab,"Generates random noise (subsequent random values in the range of -1..+1)",0,1,0, NULL,false, 0));
    190 
    191      static int Sinus_xy[]={46,3,12,75,50,71,37,62,28,50,25,37,28,28,37,25,50,28,62,37,71,50,75,62,71,71,62,75,50,1,75,50,100,50,5,35,50,40,35,45,35,55,65,60,65,65,50};   
     194addClass(new NeuroClass(NI_Random_tab,"Generates random noise (subsequent random values in the range of -1..+1)",0,1,0, NULL,false, 0, 3));
     195
     196      static int Sinus_xy[]={46,3,12,75,50,71,37,62,28,50,25,37,28,28,37,25,50,28,62,37,71,50,75,62,71,71,62,75,50,1,75,50,100,50,5,35,50,40,35,45,35,55,65,60,65,65,50};   
    192197static ParamEntry NI_Sinus_tab[]={
    193198{"Sinus generator",1, 2 ,"Sin",},
     
    197202 
    198203{0,0,0,},};
    199 addClass(new NeuroClass(NI_Sinus_tab,"Output frequency = f0+input",1,1,0, Sinus_xy,false, 0));
     204addClass(new NeuroClass(NI_Sinus_tab,"Output frequency = f0+input",1,1,0, Sinus_xy,false, 0, 3));
  • cpp/frams/neuro/neurofactory.h

    r790 r932  
    11// This file is a part of Framsticks SDK.  http://www.framsticks.com/
    2 // Copyright (C) 1999-2015  Maciej Komosinski and Szymon Ulatowski.
     2// Copyright (C) 1999-2020  Maciej Komosinski and Szymon Ulatowski.
    33// See LICENSE.txt for details.
    44
     
    77
    88#include <frams/model/modelparts.h>
     9#include <frams/model/model.h>
    910#include <map>
    1011
     
    1819        NeuroImpl* setImplementation(const SString& classname, NeuroImpl *ni, bool deleteold = 1);
    1920        NeuroImpl* getImplementation(NeuroClass *nc);
    20         class NeuroImpl* createNeuroImpl(Neuro *n)
     21        class NeuroImpl* createNeuroImpl(Neuro *n, Model::ShapeType shape_type)
    2122        {
    22                 NeuroClass *nc = n->getClass(); if (!nc) return 0; return createNeuroImpl(nc);
     23                NeuroClass *nc = n->getClass(); if (!nc) return 0; return createNeuroImpl(nc, shape_type);
    2324        }
    24         class NeuroImpl* createNeuroImpl(NeuroClass *nc);
     25        class NeuroImpl* createNeuroImpl(NeuroClass *nc, Model::ShapeType shape_type);
    2526
    2627        void setStandardImplementation();
  • cpp/frams/neuro/neuroimpl.cpp

    r896 r932  
    11// This file is a part of Framsticks SDK.  http://www.framsticks.com/
    2 // Copyright (C) 1999-2018  Maciej Komosinski and Szymon Ulatowski.
     2// Copyright (C) 1999-2020  Maciej Komosinski and Szymon Ulatowski.
    33// See LICENSE.txt for details.
    44
     
    4646        , ChannelSpace *ch
    4747#endif
    48         )
     48)
    4949        :mod(model), config(conf),
    5050        isbuilt(1), errorcount(0)
     
    6969        for (i = 0; n = mod.getNeuro(i); i++)
    7070        {
    71                 ni = conf.factory->createNeuroImpl(n);
     71                ni = conf.factory->createNeuroImpl(n, mod.getShapeType());
    7272                n->userdata[mytags_id] = ni;
    7373                if (!ni)
     
    8585        for (i = 0; n = mod.getNeuro(i); i++)
    8686        {
    87                 n->state += (rndDouble(1) - 0.5)*config.randominit;
     87                n->state += (rndDouble(1) - 0.5) * config.randominit;
    8888                ni = (NeuroImpl*)n->userdata[mytags_id];
    8989                if (!ni) continue;
     
    9898                ni->status = NeuroImpl::InitOk;
    9999                int order = ni->getSimOrder();
    100                 if (order < 0) order = 0; else if (order>2) order = 2;
     100                if (order < 0) order = 0; else if (order > 2) order = 2;
    101101                if (order < minorder) minorder = order;
    102102                if (order > maxorder) maxorder = order;
     
    189189double NeuroImpl::getNewState(int channel)
    190190{
    191         if (neuro->flags&Neuro::HoldState) return getState(channel);
     191        if (neuro->flags & Neuro::HoldState) return getState(channel);
    192192        if (channel >= channels) channel = channels - 1;
    193193        if (channel <= 0) { return newstate; }
     
    204204void NeuroImpl::commit()
    205205{
    206         if (!(neuro->flags&Neuro::HoldState))
     206        if (!(neuro->flags & Neuro::HoldState))
    207207        {
    208208                if (channels > 1)
     
    211211                if (owner->getConfig().nnoise > 0.0)
    212212                {
    213                         neuro->state += RndGen.GaussStd()*owner->getConfig().nnoise;
     213                        neuro->state += RndGen.GaussStd() * owner->getConfig().nnoise;
    214214                        if (channels > 1)
    215215                                for (int i = 0; i < chstate.size(); i++)
    216                                         chstate(0) += RndGen.GaussStd()*owner->getConfig().nnoise;
     216                                        chstate(0) += RndGen.GaussStd() * owner->getConfig().nnoise;
    217217                }
    218218        }
     
    270270        double w;
    271271        while (inp = neuro->getInput(startwith++, w))
    272                 sum += inp->state*w;
     272                sum += inp->state * w;
    273273        return sum;
    274274}
  • cpp/frams/neuro/neuroimpl.h

    r721 r932  
    11// This file is a part of Framsticks SDK.  http://www.framsticks.com/
    2 // Copyright (C) 1999-2018  Maciej Komosinski and Szymon Ulatowski.
     2// Copyright (C) 1999-2020  Maciej Komosinski and Szymon Ulatowski.
    33// See LICENSE.txt for details.
    44
     
    8282                , ChannelSpace *ch = 0
    8383#endif
    84                 );
     84        );
    8585        ~NeuroNetImpl();
    8686        void simulateNeuroNet();
     
    223223        virtual int lateinit() { return 1; }
    224224        /** calculate 'newstate - implementation dependent */
    225         virtual void go(){}
     225        virtual void go() {}
    226226        /** for neurons doing some physical actions (called each simulation step when nnspeed!=1.0) */
    227         virtual void goPhysics(){}
     227        virtual void goPhysics() {}
    228228
    229229        int getSimOrder() { return simorder; }
     
    287287        PARAMGETDEF(cstate) { arg1->setDouble(neuro->state); }
    288288        PARAMSETDEF(cstate) { setCurrentState(arg1->getDouble()); return 0; }
    289         PARAMGETDEF(hold) { arg1->setInt((neuro->flags&(Neuro::HoldState)) ? 1 : 0); }
    290         PARAMSETDEF(hold) { neuro->flags = (neuro->flags&~Neuro::HoldState) | (arg1->getInt() ? Neuro::HoldState : 0); return 0; }
     289        PARAMGETDEF(hold) { arg1->setInt((neuro->flags & (Neuro::HoldState)) ? 1 : 0); }
     290        PARAMSETDEF(hold) { neuro->flags = (neuro->flags & ~Neuro::HoldState) | (arg1->getInt() ? Neuro::HoldState : 0); return 0; }
    291291        PARAMGETDEF(channels) { arg1->setInt(getChannelCount()); }
    292292        PARAMSETDEF(channels) { setChannelCount(arg1->getInt()); return 0; }
Note: See TracChangeset for help on using the changeset viewer.