Changeset 973 for cpp/frams/genetics/fB
- Timestamp:
- 07/03/20 00:37:13 (4 years ago)
- Location:
- cpp/frams/genetics/fB
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
cpp/frams/genetics/fB/fB_conv.cpp
r954 r973 1 1 // This file is a part of Framsticks SDK. http://www.framsticks.com/ 2 // Copyright (C) 1999-20 18Maciej Komosinski and Szymon Ulatowski.2 // Copyright (C) 1999-2020 Maciej Komosinski and Szymon Ulatowski. 3 3 // See LICENSE.txt for details. 4 4 … … 80 80 int endoffset = 0; 81 81 if (gene.indexOf("zz", 0) != -1) endoffset = 2; 82 if (gene.len () - endoffset < 3)82 if (gene.length() - endoffset < 3) 83 83 { 84 84 fH_StickHandle *handle = new fH_StickHandle(dims, start, end); … … 124 124 if (gene.indexOf("zz", 0) != -1) endoffset = 2; 125 125 int nclassdefcount = 1; 126 while (z < gene.len () - endoffset)126 while (z < gene.length() - endoffset) 127 127 { 128 128 if (processNextLetter(creature, handle, par, gene, propindex, z, ranges, nclassdefcount) == -1) … … 185 185 } 186 186 nextid++; 187 } 188 while (genotype[nextid] == '"'); 187 } while (genotype[nextid] == '"'); 189 188 i = nextid; 190 189 } -
cpp/frams/genetics/fB/fB_general.h
r802 r973 1 1 // This file is a part of Framsticks SDK. http://www.framsticks.com/ 2 // Copyright (C) 1999-20 18Maciej Komosinski and Szymon Ulatowski.2 // Copyright (C) 1999-2020 Maciej Komosinski and Szymon Ulatowski. 3 3 // See LICENSE.txt for details. 4 4 … … 35 35 do { 36 36 count++; 37 if (start < genotype.len ())37 if (start < genotype.length()) 38 38 result = getNextGene(start, genotype, tmp, start); 39 39 else … … 52 52 do { 53 53 count++; 54 if (start < geno.len ())54 if (start < geno.length()) 55 55 getNextGene(start, geno, tmp, start); 56 56 else … … 89 89 } while (quotecount % 2 != 0 && end != -1); 90 90 91 if (end == -1) end = genotype.len ();91 if (end == -1) end = genotype.length(); 92 92 else end += 2; 93 93 start -= 1; … … 124 124 } while (quotecount % 2 != 0 && end != -1); 125 125 126 if (end == -1) end = genotype.len ();126 if (end == -1) end = genotype.length(); 127 127 else end += 2; 128 128 start -= 1; -
cpp/frams/genetics/fB/fB_oper.cpp
r961 r973 47 47 int endoffset = 0; 48 48 if (gene.indexOf("zz", 0) != -1) endoffset = 2; 49 if (gene.len () - endoffset < 3)49 if (gene.length() - endoffset < 3) 50 50 { 51 51 return true; // genes with length < 3 are always sticks … … 83 83 } 84 84 // check if rest of characters are lowercase 85 for (int i = genstart; i < genotype.len (); i++)85 for (int i = genstart; i < genotype.length(); i++) 86 86 { 87 87 if (!islower(genotype[i])) … … 144 144 fix = true; 145 145 } 146 for (int i = pos; i < genotype.len (); i++)146 for (int i = pos; i < genotype.length(); i++) 147 147 { 148 148 // if character is not alphabetic - error … … 208 208 std::list<SString> res; 209 209 int i = 0; 210 while (i < genotype.len ())210 while (i < genotype.length()) 211 211 { 212 212 // if character is not alphabetic - error … … 252 252 std::advance(it, rndid); 253 253 SString t = (*it); 254 if ((*it).len () == 1)254 if ((*it).length() == 1) 255 255 { 256 256 if (rndUint(2) == 0) … … 264 264 else (*it).directWrite()[0] = (*it)[0] + 1; 265 265 } 266 chg = 1.0 / line.len ();266 chg = 1.0 / line.length(); 267 267 } 268 268 else … … 270 270 // first method needs to extract quotes 271 271 SString def = (*it); 272 def = def.substr(1, def.len () - 2);272 def = def.substr(1, def.length() - 2); 273 273 Geno_fH::mutateNeuronProperties(def); 274 274 SString res = "\""; … … 276 276 res += "\""; 277 277 (*it) = res; 278 chg = (double)def.len () / line.len();278 chg = (double)def.length() / line.length(); 279 279 } 280 280 line = detokenizeSequence(&tokenized); … … 296 296 res += "\""; 297 297 tokenized.insert(it, res); 298 chg = (double)classdef.len () / line.len();298 chg = (double)classdef.length() / line.length(); 299 299 line = detokenizeSequence(&tokenized); 300 300 break; … … 304 304 case FB_INSERTION: 305 305 { 306 chg = 1.0 / line.len ();306 chg = 1.0 / line.length(); 307 307 std::list<SString> tokenized = tokenizeSequence(line); 308 308 int rndid = rndUint(tokenized.size()); // select random insertion point … … 317 317 case FB_DELETION: 318 318 { 319 chg = 1.0 / line.len ();319 chg = 1.0 / line.length(); 320 320 std::list<SString> tokenized = tokenizeSequence(line); 321 321 std::list<SString>::iterator it = tokenized.begin(); … … 332 332 SString gene = fB_GenoHelpers::getGene(rndgene, line, start, end); 333 333 if (gene.indexOf("zz", 0) == -1) gene += "zz"; 334 chg = (float)gene.len () / line.len();334 chg = (float)gene.length() / line.length(); 335 335 line = gene + line; 336 336 break; … … 364 364 // line.substr(cuts[1], cuts[2] - cuts[1]) + first + line.substr(cuts[3]); 365 365 line = detokenizeSequence(&res); 366 chg = (float)(cuts[3] - cuts[2] + cuts[1] - cuts[0]) / line.len ();366 chg = (float)(cuts[3] - cuts[2] + cuts[1] - cuts[0]) / line.length(); 367 367 break; 368 368 } … … 412 412 // add this gene to the beginning of the second parent genotype 413 413 child2 = gene + parent2; 414 chg2 = (float)parent2.len () / (float)child2.len();414 chg2 = (float)parent2.length() / (float)child2.length(); 415 415 // do the same for second parent 416 416 choice = rndUint(fB_GenoHelpers::geneCount(parent2)); 417 417 gene = fB_GenoHelpers::getGene(choice, parent2, start, end); 418 418 child1 = gene + parent1; 419 chg1 = (float)parent1.len () / (float)child1.len();419 chg1 = (float)parent1.length() / (float)child1.length(); 420 420 break; 421 421 } … … 523 523 free(g1); 524 524 free(g2); 525 if (child1.len () > 0 && child2.len() == 0)525 if (child1.length() > 0 && child2.length() == 0) 526 526 { 527 527 child1 = strdims + "\n" + child1; … … 529 529 g2 = strdup(""); 530 530 } 531 else if (child2.len () > 0 && child1.len() == 0)531 else if (child2.length() > 0 && child1.length() == 0) 532 532 { 533 533 child2 = strdims + "\n" + child2;
Note: See TracChangeset
for help on using the changeset viewer.