Changeset 896 for cpp/frams/genetics/genooperators.cpp
- Timestamp:
- 11/30/19 01:30:22 (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
cpp/frams/genetics/genooperators.cpp
r801 r896 38 38 int i; 39 39 for (i = 0; i < count; i++) sum += probtab[i]; 40 double sel = rnd 01*sum;40 double sel = rndDouble(sum); 41 41 for (sum = 0, i = 0; i < count; i++) { sum += probtab[i]; if (sel < sum) return i; } 42 42 return -1; … … 81 81 neucls = n->getClass() == NULL ? 0 : n->getClass()->getProperties().getPropCount(); 82 82 if (neuext + neucls == 0) return -1; //no properties in this neuron 83 int index = r andomN(neuext + neucls);83 int index = rndUint(neuext + neucls); 84 84 if (index >= neuext) index = index - neuext + 100; 85 85 return index; … … 142 142 { 143 143 result = int(result + 0.5); 144 if (result == current) result += r andomN(2) * 2 - 1; //force some change144 if (result == current) result += rndUint(2) * 2 - 1; //force some change 145 145 } 146 146 else … … 238 238 if (Neuro::getClass(i)->genactive) 239 239 active.push_back(Neuro::getClass(i)); 240 if (active.size() == 0) return NULL; else return active[r andomN(active.size())];240 if (active.size() == 0) return NULL; else return active[rndUint(active.size())]; 241 241 } 242 242 … … 247 247 if (Neuro::getClass(i)->genactive && Neuro::getClass(i)->getPreferredOutput() != 0) 248 248 active.push_back(Neuro::getClass(i)); 249 if (active.size() == 0) return NULL; else return active[r andomN(active.size())];249 if (active.size() == 0) return NULL; else return active[rndUint(active.size())]; 250 250 } 251 251 … … 256 256 if (Neuro::getClass(i)->genactive && Neuro::getClass(i)->getPreferredInputs() != 0) 257 257 active.push_back(Neuro::getClass(i)); 258 if (active.size() == 0) return NULL; else return active[r andomN(active.size())];258 if (active.size() == 0) return NULL; else return active[rndUint(active.size())]; 259 259 } 260 260 … … 265 265 if (Neuro::getClass(i)->genactive && Neuro::getClass(i)->getPreferredOutput() != 0 && Neuro::getClass(i)->getPreferredInputs() == 0) 266 266 active.push_back(Neuro::getClass(i)); 267 if (active.size() == 0) return NULL; else return active[r andomN(active.size())];267 if (active.size() == 0) return NULL; else return active[rndUint(active.size())]; 268 268 } 269 269 … … 274 274 if (NClist[i]->getPreferredOutput() != 0) //this NeuroClass provides output 275 275 allowed.push_back(i); 276 if (allowed.size() == 0) return -1; else return allowed[r andomN(allowed.size())];276 if (allowed.size() == 0) return -1; else return allowed[rndUint(allowed.size())]; 277 277 } 278 278 … … 283 283 if (NClist[i]->getPreferredInputs() != 0) //this NeuroClass wants one input connection or more 284 284 allowed.push_back(i); 285 if (allowed.size() == 0) return -1; else return allowed[r andomN(allowed.size())];285 if (allowed.size() == 0) return -1; else return allowed[rndUint(allowed.size())]; 286 286 } 287 287 … … 291 291 for (size_t i = 0; i < strlen(choices); i++) if (!strchrn0(excluded, choices[i])) allowed_count++; 292 292 if (allowed_count == 0) return -1; //no char is allowed 293 int rnd_index = r andomN(allowed_count) + 1;293 int rnd_index = rndUint(allowed_count) + 1; 294 294 allowed_count = 0; 295 295 for (size_t i = 0; i < strlen(choices); i++)
Note: See TracChangeset
for help on using the changeset viewer.