Changeset 896 for cpp/frams/genetics/f4
- Timestamp:
- 11/30/19 01:30:22 (5 years ago)
- Location:
- cpp/frams/genetics/f4
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
cpp/frams/genetics/f4/f4_general.cpp
r853 r896 1210 1210 int n = count(); 1211 1211 // pick a random node, between 0 and n-1 1212 return ordNode(r andomN(n));1212 return ordNode(rndUint(n)); 1213 1213 } 1214 1214 … … 1355 1355 { 1356 1356 int i, j, res, t; 1357 char tc1, tc2, tc3; // tc3 is only to ensure that in the end of neuron parameter definition1357 char tc1, tc2, tc3; // tc3 is only to ensure that neuron parameter definition is completed 1358 1358 int relfrom; 1359 1359 double w; -
cpp/frams/genetics/f4/f4_oper.cpp
r779 r896 158 158 // "X>" or "N>" 159 159 f4_node *n5 = NULL; 160 double pr = rnd 01;160 double pr = rndDouble(1); 161 161 pr -= 0.5; 162 162 if (pr < 0) n5 = new f4_node('X', n2, n2->pos); … … 204 204 n1->parent = n2; 205 205 // now with 50% chance swap children 206 if (r andomN(2) == 0)206 if (rndUint(2) == 0) 207 207 { 208 208 n3 = n2->child; … … 275 275 // choose a simple node from ADD_SIMPLE_CODES 276 276 n1->parent->removeChild(n1); 277 //f4_node *n2 = new f4_node(ADD_SIMPLE_CODES[r andomN(strlen(ADD_SIMPLE_CODES))], n1->parent, n1->parent->pos);277 //f4_node *n2 = new f4_node(ADD_SIMPLE_CODES[rndUint(strlen(ADD_SIMPLE_CODES))], n1->parent, n1->parent->pos); 278 278 int modifierid = GenoOperators::getRandomChar(all_modifiers, excluded_modifiers.c_str()); 279 279 f4_node *n2 = new f4_node(all_modifiers[modifierid], n1->parent, n1->parent->pos); … … 333 333 n2->removeChild(n1); 334 334 // n1 has two children. pick one randomly 50-50, destroy other 335 if (r andomN(2) == 0)335 if (rndUint(2) == 0) 336 336 { 337 337 n1->child->parent = n2; … … 429 429 430 430 // 35% chance one of *GTS 431 prob1 = rnd 01;431 prob1 = rndDouble(1); 432 432 prob1 -= 0.35f; 433 433 if (prob1 < 0) … … 468 468 case 0: // change type 469 469 // 80% for link, 20% for random sensor 470 if (rnd 01< 0.2f)470 if (rndDouble(1) < 0.2f) 471 471 { 472 472 cl = GenoOperators::getRandomNeuroClassWithOutputAndNoInputs(); … … 497 497 void Geno_f4::nparNodeMakeRandom(f4_node *nn) const 498 498 { 499 int sign = (int) (2.0f * rnd01);500 int param = (int) (3.0f * rnd01);499 int sign = (int)rndDouble(2); 500 int param = (int)rndDouble(3); 501 501 if (param > 2) param = 2; 502 502 nn->l1 = sign; … … 512 512 // change count 513 513 count = nn->i1; 514 prob1 = rnd 01;514 prob1 = rndDouble(1); 515 515 if (prob1 < 0.5f) count++; 516 516 else count--; … … 699 699 // decide amounts of crossover, 0.25-0.75 700 700 // adam: seems 0.1-0.9 -- MacKo 701 chg1 = 0.1 f + 0.8f*rnd01;702 chg2 = 0.1 f + 0.8f*rnd01;701 chg1 = 0.1 + rndDouble(0.8); 702 chg2 = 0.1 + rndDouble(0.8); 703 703 704 704 copy1 = root1.duplicate();
Note: See TracChangeset
for help on using the changeset viewer.