Changeset 1273 for cpp/frams/genetics/fL/fL_general.cpp
- Timestamp:
- 09/09/23 15:10:49 (14 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
cpp/frams/genetics/fL/fL_general.cpp
r973 r1273 1 1 // This file is a part of Framsticks SDK. http://www.framsticks.com/ 2 // Copyright (C) 1999-202 0Maciej Komosinski and Szymon Ulatowski.2 // Copyright (C) 1999-2023 Maciej Komosinski and Szymon Ulatowski. 3 3 // See LICENSE.txt for details. 4 4 … … 9 9 #include <iterator> 10 10 11 const char *fL_part_names[FL_PART_PROPS_COUNT] = { " dn", "fr", "ing", "as" };12 const char *fL_part_fullnames[FL_PART_PROPS_COUNT] = { " details", "friction", "ingestion", "assimilation" };13 14 const char *fL_joint_names[FL_JOINT_PROPS_COUNT] = { " stif", "rotstif", "stam" };15 const char *fL_joint_fullnames[FL_JOINT_PROPS_COUNT] = { " stiffness", "rotationstiffness", "stamina" };11 const char *fL_part_names[FL_PART_PROPS_COUNT] = { "fr" }; // "dn", "ing", "as" }; 12 const char *fL_part_fullnames[FL_PART_PROPS_COUNT] = { "friction" }; // "density", "ingestion", "assimilation" }; 13 14 const char *fL_joint_names[FL_JOINT_PROPS_COUNT] = { "rotstif" }; //"stif", , "stam" }; //see the comment to fH_joint_names in fH_general.cpp 15 const char *fL_joint_fullnames[FL_JOINT_PROPS_COUNT] = { "rotation stiffness" }; //"stiffness", "stamina" }; 16 16 17 17 #define FIELDSTRUCT fL_Word … … 502 502 fL_Word *stick = new fL_Word(true); 503 503 stick->name = "S"; 504 stick->npar = 8;504 stick->npar = FL_PART_PROPS_COUNT + FL_JOINT_PROPS_COUNT + 1; //MacKo 2023-07: was hardcoded "8" but crashed when the number of props in Part and Joint was decreased; I think it should be like it is now (4+3+1 - or another value depending on prop counts) 505 505 for (int i = 0; i < FL_PART_PROPS_COUNT; i++) 506 506 { 507 507 stick->mut.addProperty(NULL, fL_part_names[i], "s", fL_part_fullnames[i], fL_part_fullnames[i], PARAM_CANOMITNAME, 0, -1); 508 508 } 509 510 509 for (int i = 0; i < FL_JOINT_PROPS_COUNT; i++) 511 510 { … … 1096 1095 { 1097 1096 delete newpart; 1098 logMessage("fL_Builder", "developModel", LOG_ERROR, 1099 "Error parsing word parameter"); 1097 logMessage("fL_Builder", "developModel", LOG_ERROR, "Error parsing word parameter"); 1100 1098 return 1; 1101 1099 } … … 1123 1121 if (word->parevals[FL_PART_PROPS_COUNT + i]->evaluateRPN(jointprop) != 0) 1124 1122 { 1125 logMessage("fL_Builder", "developModel", LOG_ERROR, 1126 "Error parsing word parameter"); 1123 logMessage("fL_Builder", "developModel", LOG_ERROR, "Error parsing word parameter"); 1127 1124 delete newjoint; 1128 1125 return 1; … … 1153 1150 } 1154 1151 model->addNeuro(neu); 1152 1153 1154 // MacKo 2023-07: embody (i.e., attach to body) sensors and effectors. 1155 // Ad hoc modification; should be reconsidered as it was added without reminding and understanding of the entire logic of the phenotype development and assumptions, and may not be "the best performing" or "the most reasonable" approach. Without this embodiment, genotypes with sensors and effectors not attached to body had warnings (such neurons "could not be initialized") so such genotypes were not accepted when creatwarnfail==1; even with creatwarnfail==0, non-embodied sensor and effector neurons were useless. 1156 //printf("Neuron: -------------- %s\n", details.c_str()); 1157 switch (neu->getClass()->getPreferredLocation()) 1158 { 1159 case NeuroClass::PrefLocation::PREFER_PART: //attach to currstate.currpart 1160 if (currstate.currpart != NULL) 1161 neu->attachToPart(currstate.currpart); 1162 break; 1163 case NeuroClass::PrefLocation::PREFER_JOINT: //attach to the last joint incident with currstate.currpart 1164 if (currstate.currpart != NULL) 1165 { 1166 Joint *j = NULL; 1167 for (int i = 0; i < model->getJointCount(); i++) 1168 { 1169 Joint *jj = model->getJoint(i); 1170 if (jj->part1 == currstate.currpart || jj->part2 == currstate.currpart) 1171 j = jj; 1172 } 1173 if (j != NULL) 1174 neu->attachToJoint(j); 1175 } 1176 break; 1177 default: 1178 break; 1179 } 1180 1181 1155 1182 if (using_mapping) neu->addMapping(IRange(word->begin, word->end)); 1156 1183 if (neu->getClass()->getPreferredInputs() != 0) … … 1251 1278 { 1252 1279 connsbuffer[i].second->addInput(connsbuffer[i].second, weight); 1253 if (using_mapping) neu->addMapping(1280 if (using_mapping) connsbuffer[i].second->addMapping( //MacKo 2023-07: changed 'neu' (which is NULL here so crashed) to connsbuffer[i].second (no guarantee this is a proper fix, only inspired by the analogy to the difference in both branches of "if" in the line above) 1254 1281 IRange((*connsbuffer[i].first)->begin, 1255 1282 (*connsbuffer[i].first)->end));
Note: See TracChangeset
for help on using the changeset viewer.