Changeset 81 for cpp/gdk/neuroimpl.cpp
- Timestamp:
- 02/08/13 03:29:17 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
cpp/gdk/neuroimpl.cpp
r72 r81 6 6 #include "neurofactory.h" 7 7 #include "rndutil.h" 8 #include "nonstd_math.h" 8 9 #ifndef GDK_WITHOUT_FRAMS 9 10 #include "creature.h" … … 38 39 {} 39 40 40 NeuroNetConfig NeuroNetConfig::globalconfig; 41 NeuroNetConfig& NeuroNetConfig::getGlobalConfig() 42 { 43 static NeuroNetConfig globalconfig; 44 return globalconfig; 45 } 41 46 42 47 ///////////////////////////////////////////////////////////////// … … 200 205 chstate=chnewstate; 201 206 neuro->state=newstate; 202 if (NeuroNetConfig::g lobalconfig.nnoise>0.0)207 if (NeuroNetConfig::getGlobalConfig().nnoise>0.0) 203 208 { 204 neuro->state+=RndGen.GaussStd()*NeuroNetConfig::g lobalconfig.nnoise;209 neuro->state+=RndGen.GaussStd()*NeuroNetConfig::getGlobalConfig().nnoise; 205 210 if (channels>1) 206 211 for(int i=0;i<chstate.size();i++) 207 chstate(0)+=RndGen.GaussStd()*NeuroNetConfig::g lobalconfig.nnoise;212 chstate(0)+=RndGen.GaussStd()*NeuroNetConfig::getGlobalConfig().nnoise; 208 213 } 209 214 } … … 274 279 int zero=0; 275 280 par.load2(neuro->getClassParams(),zero); 281 } 282 283 Param& NeuroImpl::getStaticParam() 284 { 285 static Param p(neuroimpl_tab,0,"Neuro"); 286 return p; 276 287 } 277 288 … … 340 351 ParamEntry neurosignals_paramtab[]= 341 352 { 342 {"NeuroSignals",1,8,"NeuroSignals","Signals attached to theneuron.\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.",}, 343 354 344 355 #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)"},356 SIGNPAR_ADD(""), 357 SIGNPAR_RECEIVE(""), 358 SIGNPAR_RECEIVESET(""), 359 SIGNPAR_RECEIVEFILTER(""), 360 SIGNPAR_RECEIVESINGLE(""), 350 361 #undef FIELDSTRUCT 351 362 352 363 #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),},364 SIGNSETPAR_GET, 365 SIGNSETPAR_SIZE, 366 SIGNSETPAR_CLEAR, 356 367 #undef FIELDSTRUCT 357 368 {0,0,0,}, 358 369 }; 359 Param neurosignals_param(neurosignals_paramtab,0); 360 #endif 361 362 Param st_neuroimplparam(neuroimpl_tab,0,"Neuro"); 370 371 Param& NeuroSignals::getStaticParam() 372 { 373 static Param p(neurosignals_paramtab,0); 374 return p; 375 } 376 #endif 363 377 364 378 #ifdef NEURO_SIGNALS … … 474 488 Part *pa; 475 489 if (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]))); 477 491 else 478 492 ret->setEmpty(); … … 485 499 Joint *jo; 486 500 if (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]))); 488 502 else 489 503 ret->setEmpty(); … … 534 548 void NeuroImpl::get_neurodef(ExtValue *ret) 535 549 { 536 ret->setObject(ExtObject(& st_neuroparam,neuro));550 ret->setObject(ExtObject(&Neuro::getStaticParam(),neuro)); 537 551 } 538 552
Note: See TracChangeset
for help on using the changeset viewer.