Changeset 671 for cpp/frams/genetics/f4/oper_f4.cpp
- Timestamp:
- 08/18/17 15:24:59 (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
cpp/frams/genetics/f4/oper_f4.cpp
r513 r671 1 1 // This file is a part of Framsticks SDK. http://www.framsticks.com/ 2 // Copyright (C) 1999-201 5Maciej Komosinski and Szymon Ulatowski.2 // Copyright (C) 1999-2017 Maciej Komosinski and Szymon Ulatowski. 3 3 // See LICENSE.txt for details. 4 4 … … 231 231 // must pick a node with parent, and at least one child 232 232 // already picked a node, but repeat may be needed 233 for (int i = 0; i < 10; i++) { 233 for (int i = 0; i < 10; i++) 234 { 234 235 if ((NULL != n1->parent) && (g != n1->parent)) 235 236 if (NULL != n1->child) … … 247 248 n2 = n1->parent; 248 249 n2->removeChild(n1); 249 if (NULL != n1->child) { 250 if (NULL != n1->child) 251 { 250 252 n1->child->parent = n2; 251 253 n2->addChild(n1->child); 252 254 n1->child = NULL; 253 255 } 254 if (NULL != n1->child2) { 256 if (NULL != n1->child2) 257 { 255 258 n1->child2->parent = n2; 256 259 n2->addChild(n1->child2); … … 309 312 if (i >= 20) return GENOPER_OPFAIL; 310 313 } 311 switch (n1->name) { 314 switch (n1->name) 315 { 312 316 case '<': 313 317 // swap children … … 348 352 nn->i1 = i; 349 353 nn->l1 = 0; 350 if (0 == i) { 354 if (0 == i) 355 { 351 356 // relative input link 352 357 nn->l1 = (int)(4.0f * (rnd01 - 0.5f)); … … 407 412 if (prob1 < 0.5f) count++; 408 413 else count--; 409 if (count <1) count = 1;410 if (count >REP_MAXCOUNT) count = REP_MAXCOUNT;414 if (count < 1) count = 1; 415 if (count > REP_MAXCOUNT) count = REP_MAXCOUNT; 411 416 nn->i1 = count; 412 417 } … … 464 469 if (f4_processrec(g, 0, root) || root->childCount() != 1) 465 470 { 466 delete root; return GENOPER_OPFAIL; 471 delete root; 472 return GENOPER_OPFAIL; 467 473 } // could not convert or bad: fail 468 474 // mutate one node, set chg as this percent … … 470 476 if (MutateOneValid(root, method) != GENOPER_OK) 471 477 { 472 delete root; return GENOPER_OPFAIL; 478 delete root; 479 return GENOPER_OPFAIL; 473 480 } 474 481 // OK, convert back to string
Note: See TracChangeset
for help on using the changeset viewer.