Changeset 973 for cpp/frams/genetics/fL/fL_general.cpp
- Timestamp:
- 07/03/20 00:37:13 (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
cpp/frams/genetics/fL/fL_general.cpp
r857 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 … … 76 76 { 77 77 // if position exceeds length then return false 78 if (pos >= src.len ()) return false;78 if (pos >= src.length()) return false; 79 79 int opencount = -1; 80 80 int i = pos; 81 for (; i < src.len (); i++)81 for (; i < src.length(); i++) 82 82 { 83 83 // token cannot contain branching parenthesis … … 169 169 SString temp; 170 170 temp = token.substr(tokpos); 171 temp = temp.substr(0, temp.len () - 1);171 temp = temp.substr(0, temp.length() - 1); 172 172 173 173 // if word has parameters … … 199 199 // if string is empty, then evaluate this with 0 200 200 // if sequence could not be evaluated, then return error 201 if (seq.len () > 0)201 if (seq.length() > 0) 202 202 { 203 203 eval = new MathEvaluation(numparams); … … 217 217 } 218 218 } 219 else if (word->npar == 0 && temp.len () > 0)219 else if (word->npar == 0 && temp.length() > 0) 220 220 { 221 221 SString message = "Too many parameters for word: "; … … 351 351 { 352 352 // if word already exist, then return error 353 if (this->name.len () == 0)353 if (this->name.length() == 0) 354 354 { 355 355 logMessage("fL_Word", "processDefinition", LOG_ERROR, "Axiom name is empty"); … … 456 456 switch (type) 457 457 { 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 458 case fLElementType::TERM: 459 { 460 tab = fL_word_paramtab; 461 obj = new fL_Word(); 462 break; 463 } 464 case fLElementType::INFO: 465 { 466 tab = fL_builder_paramtab; 467 obj = this; 468 break; 469 } 470 case fLElementType::RULE: 471 { 472 tab = fL_rule_paramtab; 473 obj = new fL_Rule(begin, end); 474 break; 475 } 476 default: 477 tab = NULL; 478 obj = NULL; 479 break; 480 480 } 481 481 Param par(tab); … … 573 573 while (genotype.getNextToken(pos, line, '\n')) 574 574 { 575 if (line.len () > 0)575 if (line.length() > 0) 576 576 { 577 577 // words can be defined in the beginning of genotype … … 851 851 { 852 852 SString t = par.getString(q); 853 if (t.len () > 0)853 if (t.length() > 0) 854 854 { 855 855 fL_Word *attrword = NULL; … … 957 957 } 958 958 double partprop = (ppar.getDoubleById(fL_part_names[i]) * alterationcount + 959 959 currval) / (alterationcount + 1.0); 960 960 ppar.setDoubleById(fL_part_names[i], partprop); 961 961 } … … 1097 1097 delete newpart; 1098 1098 logMessage("fL_Builder", "developModel", LOG_ERROR, 1099 1099 "Error parsing word parameter"); 1100 1100 return 1; 1101 1101 } … … 1124 1124 { 1125 1125 logMessage("fL_Builder", "developModel", LOG_ERROR, 1126 1126 "Error parsing word parameter"); 1127 1127 delete newjoint; 1128 1128 return 1; … … 1162 1162 else if (word->name == "C") 1163 1163 { 1164 connsbuffer.push_back({ w, currstate.currneuron});1164 connsbuffer.push_back({ w, currstate.currneuron }); 1165 1165 } 1166 1166 else if (word->name.startsWith("rot")) … … 1182 1182 if (word->name == "rotX") 1183 1183 { 1184 rotmatrix.rotate(Pt3D(rot, 0,0));1184 rotmatrix.rotate(Pt3D(rot, 0, 0)); 1185 1185 } 1186 1186 else if (word->name == "rotY") 1187 1187 { 1188 rotmatrix.rotate(Pt3D(0, rot,0));1188 rotmatrix.rotate(Pt3D(0, rot, 0)); 1189 1189 } 1190 1190 else if (word->name == "rotZ") 1191 1191 { 1192 rotmatrix.rotate(Pt3D(0, 0,rot));1192 rotmatrix.rotate(Pt3D(0, 0, rot)); 1193 1193 } 1194 1194 currstate.direction = rotmatrix.transform(currstate.direction); … … 1212 1212 { 1213 1213 if (connsbuffer[i].second == NULL || 1214 1214 (connsbuffer[i].second->getClass()->getPreferredInputs() != -1 && 1215 1215 connsbuffer[i].second->getInputCount() >= 1216 1216 connsbuffer[i].second->getClass()->getPreferredInputs())) … … 1225 1225 SString attr = par.getStringById(FL_PE_CONN_ATTR); 1226 1226 fL_Word *attractor = NULL; 1227 if (attr.len () > 0)1227 if (attr.length() > 0) 1228 1228 { 1229 1229 createWord(attr, attractor, 0, (*connsbuffer[i].first)->begin, (*connsbuffer[i].first)->end); … … 1236 1236 { 1237 1237 logMessage("fL_Builder", "developModel", LOG_ERROR, 1238 1238 "Error parsing word parameter"); 1239 1239 delete attractor; 1240 1240 return 1; … … 1245 1245 connsbuffer[i].second->addInput(neu, weight); 1246 1246 if (using_mapping) neu->addMapping( 1247 1248 1247 IRange((*connsbuffer[i].first)->begin, 1248 (*connsbuffer[i].first)->end)); 1249 1249 } 1250 1250 else … … 1252 1252 connsbuffer[i].second->addInput(connsbuffer[i].second, weight); 1253 1253 if (using_mapping) neu->addMapping( 1254 1255 1254 IRange((*connsbuffer[i].first)->begin, 1255 (*connsbuffer[i].first)->end)); 1256 1256 } 1257 1257 delete attractor; … … 1286 1286 m->open(using_checkpoints); 1287 1287 bool wordsexceeded = false; 1288 for (; t <= time; t += timestamp)1288 for (; t <= time; t += timestamp) 1289 1289 { 1290 1290 alterTimedProperties(t); // always alter timed properties in the beginning … … 1293 1293 { 1294 1294 iterate(t); 1295 curriter +=1.0;1295 curriter += 1.0; 1296 1296 } 1297 1297 if (using_checkpoints) … … 1362 1362 { 1363 1363 int count = genotype.size(); 1364 for (fL_Rule *rul : rules)1364 for (fL_Rule *rul : rules) 1365 1365 { 1366 1366 count += rul->objsucc.size(); … … 1373 1373 { 1374 1374 for (std::vector<fL_Rule *>::iterator it = rules.begin(); 1375 1375 it != rules.end(); it++) 1376 1376 { 1377 1377 std::vector<fL_Rule *>::iterator it2 = it; … … 1393 1393 { 1394 1394 if ((*it)->condeval->getStringifiedRPN() == 1395 1395 (*it2)->condeval->getStringifiedRPN()) 1396 1396 { 1397 1397 todelete = true;
Note: See TracChangeset
for help on using the changeset viewer.