Changeset 81 for cpp/gdk/neuroimpl.cpp


Ignore:
Timestamp:
02/08/13 03:29:17 (11 years ago)
Author:
Maciej Komosinski
Message:

improved parsing of properties (e.g. in f0 genotypes)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • cpp/gdk/neuroimpl.cpp

    r72 r81  
    66#include "neurofactory.h"
    77#include "rndutil.h"
     8#include "nonstd_math.h"
    89#ifndef GDK_WITHOUT_FRAMS
    910#include "creature.h"
     
    3839{}
    3940
    40 NeuroNetConfig NeuroNetConfig::globalconfig;
     41NeuroNetConfig& NeuroNetConfig::getGlobalConfig()
     42{
     43static NeuroNetConfig globalconfig;
     44return globalconfig;
     45}
    4146
    4247/////////////////////////////////////////////////////////////////
     
    200205                chstate=chnewstate;
    201206        neuro->state=newstate;
    202         if (NeuroNetConfig::globalconfig.nnoise>0.0)
     207        if (NeuroNetConfig::getGlobalConfig().nnoise>0.0)
    203208                {
    204                 neuro->state+=RndGen.GaussStd()*NeuroNetConfig::globalconfig.nnoise;
     209                neuro->state+=RndGen.GaussStd()*NeuroNetConfig::getGlobalConfig().nnoise;
    205210                if (channels>1)
    206211                        for(int i=0;i<chstate.size();i++)
    207                                 chstate(0)+=RndGen.GaussStd()*NeuroNetConfig::globalconfig.nnoise;
     212                                chstate(0)+=RndGen.GaussStd()*NeuroNetConfig::getGlobalConfig().nnoise;
    208213                }
    209214        }
     
    274279int zero=0;
    275280par.load2(neuro->getClassParams(),zero);
     281}
     282
     283Param& NeuroImpl::getStaticParam()
     284{
     285static Param p(neuroimpl_tab,0,"Neuro");
     286return p;
    276287}
    277288
     
    340351ParamEntry neurosignals_paramtab[]=
    341352 {
    342 {"NeuroSignals",1,8,"NeuroSignals","Signals attached to the neuron.\nSee also: Signal, WorldSignals, CreatureSignals.\nscripts/light.neuro and scripts/seelight.neuro are simple custom neuron examples demonstrating how to send/receive signals between creatures.",},
     353{"NeuroSignals",1,8,"NeuroSignals","Signals attached to a neuron.\nSee also: Signal, WorldSignals, CreatureSignals.\nscripts/light.neuro and scripts/seelight.neuro are simple custom neuron examples demonstrating how to send/receive signals between creatures.",},
    343354
    344355#define FIELDSTRUCT NeuroSignals
    345 {"add",0,PARAM_NOSTATIC,"Add","p(s channel)",PROCEDURE(p_add),"Create a new signal"},
    346 {"receive",0,PARAM_NOSTATIC,"Receive","p f(s channel)",PROCEDURE(p_receive),"Receive the aggregated signal power in a given channel."},
    347 {"receiveSet",0,PARAM_NOSTATIC,"Receive","p oVector(s channel,f max distance)",PROCEDURE(p_receiveSet),"Get all signals in the specified range. Returns a readonly vector object containing Signal objects (individual signals can be accessed as result[0] throught result[result.size-1])."},
    348 {"receiveFilter",0,PARAM_NOSTATIC,"receive","p f(s channel,f max distance,f flavor,f filter)",PROCEDURE(p_receiveFilter),"Receive the aggregated signal power in a given channel.\n\nAdditional filtering options:\n- Max distance only receives the neighbor signals (based on their physical location)\n- Flavor filtering: only signals having the flavor close to the specified one will be received. The filter value is the maximum allowed difference."},
    349 {"receiveSingle",0,PARAM_NOSTATIC,"Receive","p oSignal(s channel,f range)",PROCEDURE(p_receiveSingle),"Find the signal source having the highest signal power (including the distance)"},
     356SIGNPAR_ADD(""),
     357SIGNPAR_RECEIVE(""),
     358SIGNPAR_RECEIVESET(""),
     359SIGNPAR_RECEIVEFILTER(""),
     360SIGNPAR_RECEIVESINGLE(""),
    350361#undef FIELDSTRUCT
    351362
    352363#define FIELDSTRUCT SignalSet
    353 {"get",0,PARAM_NOSTATIC,"Get","p oSignal(d index)",PROCEDURE(p_get),},
    354 {"size",0,1+PARAM_NOSTATIC,"Size","d",GETONLY(size),},
    355 {"clear",0,1+PARAM_NOSTATIC,"Clear","p()",PROCEDURE(p_clear),},
     364SIGNSETPAR_GET,
     365SIGNSETPAR_SIZE,
     366SIGNSETPAR_CLEAR,
    356367#undef FIELDSTRUCT
    357368{0,0,0,},
    358369 };
    359 Param neurosignals_param(neurosignals_paramtab,0);
    360 #endif
    361 
    362 Param st_neuroimplparam(neuroimpl_tab,0,"Neuro");
     370
     371Param& NeuroSignals::getStaticParam()
     372{
     373static Param p(neurosignals_paramtab,0);
     374return p;
     375}
     376#endif
    363377
    364378#ifdef NEURO_SIGNALS
     
    474488Part *pa;
    475489if (pa=neuro->getPart())
    476         ret->setObject(ExtObject(&mechpart_param,((MechPart *)pa->userdata[CreatMechObject::modeltags_id])));
     490        ret->setObject(ExtObject(&MechPart::getStaticParam(),((MechPart *)pa->userdata[CreatMechObject::modeltags_id])));
    477491else
    478492        ret->setEmpty();
     
    485499Joint *jo;
    486500if (jo=neuro->getJoint())
    487         ret->setObject(ExtObject(&mechjoint_param,((MechJoint*)jo->userdata[CreatMechObject::modeltags_id])));
     501        ret->setObject(ExtObject(&MechJoint::getStaticParam(),((MechJoint*)jo->userdata[CreatMechObject::modeltags_id])));
    488502else
    489503        ret->setEmpty();
     
    534548void NeuroImpl::get_neurodef(ExtValue *ret)
    535549{
    536 ret->setObject(ExtObject(&st_neuroparam,neuro));
     550ret->setObject(ExtObject(&Neuro::getStaticParam(),neuro));
    537551}
    538552
Note: See TracChangeset for help on using the changeset viewer.