Changeset 1226 for cpp/frams/genetics/genooperators.cpp
- Timestamp:
- 04/27/23 03:55:33 (12 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
cpp/frams/genetics/genooperators.cpp
r1032 r1226 1 1 // This file is a part of Framsticks SDK. http://www.framsticks.com/ 2 // Copyright (C) 1999-202 0Maciej Komosinski and Szymon Ulatowski.2 // Copyright (C) 1999-2023 Maciej Komosinski and Szymon Ulatowski. 3 3 // See LICENSE.txt for details. 4 4 … … 313 313 } 314 314 315 NeuroClass *GenoOperators::getRandomNeuroClassWithOutputAnd NoInputs(Model::ShapeType for_shape_type)315 NeuroClass *GenoOperators::getRandomNeuroClassWithOutputAndWantingNoInputs(Model::ShapeType for_shape_type) 316 316 { 317 317 vector<NeuroClass *> active; … … 320 320 NeuroClass *nc = Neuro::getClass(i); 321 321 if (nc->isShapeTypeSupported(for_shape_type) && nc->genactive && nc->getPreferredOutput() != 0 && nc->getPreferredInputs() == 0) 322 active.push_back(nc); 323 } 324 if (active.size() == 0) return NULL; else return active[rndUint(active.size())]; 325 } 326 327 NeuroClass *GenoOperators::getRandomNeuroClassWithOutputAndWantingNoOrAnyInputs(Model::ShapeType for_shape_type) 328 { 329 vector<NeuroClass *> active; 330 for (int i = 0; i < Neuro::getClassCount(); i++) 331 { 332 NeuroClass *nc = Neuro::getClass(i); 333 if (nc->isShapeTypeSupported(for_shape_type) && nc->genactive && nc->getPreferredOutput() != 0 && nc->getPreferredInputs() <= 0) // getPreferredInputs() should be 0 or -1 (any) 322 334 active.push_back(nc); 323 335 } … … 353 365 { 354 366 if (!strchrn0(excluded, choices[i])) allowed_count++; 355 if (allowed_count == rnd_index) return i ;367 if (allowed_count == rnd_index) return int(i); 356 368 } 357 369 return -1; //never happens 358 370 } 359 371 360 NeuroClass *GenoOperators::parseNeuroClass(char *&s )372 NeuroClass *GenoOperators::parseNeuroClass(char *&s, ModelEnum::ShapeType supported_shapetype) 361 373 { 362 374 int maxlen = (int)strlen(s); … … 365 377 for (int i = 0; i < Neuro::getClassCount(); i++) 366 378 { 367 const char *ncname = Neuro::getClass(i)->name.c_str(); 368 int ncnamelen = (int)strlen(ncname); 369 if (maxlen >= ncnamelen && ncnamelen > NClen && (strncmp(s, ncname, ncnamelen) == 0)) 370 { 371 NC = Neuro::getClass(i); 372 NClen = ncnamelen; 379 NeuroClass *nci = Neuro::getClass(i); 380 if (!nci->isShapeTypeSupported(supported_shapetype)) 381 continue; 382 const char *nciname = nci->name.c_str(); 383 int ncinamelen = (int)strlen(nciname); 384 if (maxlen >= ncinamelen && ncinamelen > NClen && (strncmp(s, nciname, ncinamelen) == 0)) 385 { 386 NC = nci; 387 NClen = ncinamelen; 373 388 } 374 389 }
Note: See TracChangeset
for help on using the changeset viewer.