Changeset 1259 for cpp/frams/genetics/f4/f4_general.cpp
- Timestamp:
- 06/22/23 03:52:39 (17 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
cpp/frams/genetics/f4/f4_general.cpp
r1249 r1259 37 37 { 38 38 nr = nnr; 39 type = CELL_UNDIFF;39 type = f4_Cell_type::CELL_UNDIFF; 40 40 dadlink = ndad; 41 41 org = NULL; … … 62 62 { 63 63 // make sure it is a stick (and not a stick f4_Cell!) 64 if (ndad->type == CELL_STICK)64 if (ndad->type == f4_Cell_type::CELL_STICK) 65 65 { 66 66 //firstend = ndad->lastend; … … 68 68 ndad->stickchildcount++; 69 69 } 70 if (ndad->type == CELL_NEURON)70 if (ndad->type == f4_Cell_type::CELL_NEURON) 71 71 { 72 72 inertia = ndad->inertia; … … 84 84 { 85 85 nr = nnr; 86 type = CELL_UNDIFF;86 type = f4_Cell_type::CELL_UNDIFF; 87 87 dadlink = ndad; 88 88 org = nO; … … 112 112 { 113 113 // make sure it is a stick (and not a stick f4_Cell!) 114 if (ndad->type == CELL_STICK)114 if (ndad->type == f4_Cell_type::CELL_STICK) 115 115 { 116 116 //firstend = ndad->lastend; … … 118 118 ndad->stickchildcount++; 119 119 } 120 if (ndad->type == CELL_NEURON)120 if (ndad->type == f4_Cell_type::CELL_NEURON) 121 121 { 122 122 inertia = ndad->inertia; … … 173 173 174 174 // error: sticks cannot divide 175 if (type == CELL_STICK)175 if (type == f4_Cell_type::CELL_STICK) 176 176 { 177 177 // cannot fix … … 181 181 182 182 // undiff divides 183 if (type == CELL_UNDIFF)183 if (type == f4_Cell_type::CELL_UNDIFF) 184 184 { 185 185 // commacount is set only when daughter turns into X … … 194 194 } 195 195 // a neuron divides: create a new, duplicate connections 196 if (type == CELL_NEURON)196 if (type == f4_Cell_type::CELL_NEURON) 197 197 { 198 198 // daughter cell … … 203 203 repeat.clear(); 204 204 // it is a neuron from start 205 tmp->type = CELL_NEURON;205 tmp->type = f4_Cell_type::CELL_NEURON; 206 206 // it has the same type as the parent neuron 207 207 tmp->neuclass = neuclass; … … 257 257 { 258 258 // error: still undiff 259 if (type == CELL_UNDIFF)259 if (type == f4_Cell_type::CELL_UNDIFF) 260 260 { 261 261 // fix it: insert an 'X' … … 301 301 { 302 302 // error: if neuron 303 if (type == CELL_NEURON)303 if (type == f4_Cell_type::CELL_NEURON) 304 304 { 305 305 // fix: delete it … … 331 331 { 332 332 // error: if neuron 333 if (type == CELL_NEURON) //some neurons have the same single-letter names as modifiers (for example G,S,D), but they are supposed to have is_neuroclass==true so they should indeed not be handled here333 if (type == f4_Cell_type::CELL_NEURON) //some neurons have the same single-letter names as modifiers (for example G,S,D), but they are supposed to have is_neuroclass==true so they should indeed not be handled here 334 334 {//however, what we see here is actually modifiers such as IdqEbWL (so not valid neuroclasses) that occurred within an already differentiated cell of type==CELL_NEURON. 335 335 //printf("Handled as a modifier, but type==CELL_NEURON: '%c'\n", name); … … 346 346 // turn undiff. cell into a stick 347 347 // error: already differentiated 348 if (type != CELL_UNDIFF)348 if (type != f4_Cell_type::CELL_UNDIFF) 349 349 { 350 350 // fix: delete this node … … 352 352 return; // error code set -> stop further cells development 353 353 } 354 type = CELL_STICK;354 type = f4_Cell_type::CELL_STICK; 355 355 // fix dad commacount and own anglepos 356 356 if (dadlink != NULL) … … 367 367 // connection to neuron 368 368 // error: not a neuron 369 if (type != CELL_NEURON)369 if (type != f4_Cell_type::CELL_NEURON) 370 370 { 371 371 // fix: delete it … … 384 384 for (int i = 0; i < org->cell_count; i++) 385 385 { 386 if (org->C[i]->type == CELL_NEURON) neu_counter++;386 if (org->C[i]->type == f4_Cell_type::CELL_NEURON) neu_counter++; 387 387 if (org->C[i] == this) { this_index = neu_counter - 1; break; } 388 388 } … … 398 398 for (from = 0; from < org->cell_count; from++) 399 399 { 400 if (org->C[from]->type == CELL_NEURON) neu_counter++;400 if (org->C[from]->type == f4_Cell_type::CELL_NEURON) neu_counter++; 401 401 if (from_index == (neu_counter - 1)) break; 402 402 } … … 457 457 // neuron parameter 458 458 // error: not a neuron 459 if (type != CELL_NEURON)459 if (type != f4_Cell_type::CELL_NEURON) 460 460 { 461 461 // fix: delete it … … 513 513 { 514 514 genoRange.add(gcur->pos, gcur->pos + int(gcur->name.length()) + 2 - 1); // +2 for N: 515 if (type != CELL_UNDIFF)515 if (type != f4_Cell_type::CELL_UNDIFF) 516 516 { 517 517 // fix: delete this node … … 527 527 } 528 528 neuclass = gcur->neuclass; 529 type = CELL_NEURON;529 type = f4_Cell_type::CELL_NEURON; 530 530 // change of type also halts development, to give other 531 531 // cells a chance for adjustment. Namely, it is important … … 567 567 { 568 568 if (org->C[i]->dadlink == this) 569 if (org->C[i]->type == CELL_STICK)569 if (org->C[i]->type == f4_Cell_type::CELL_STICK) 570 570 stickchildcount++; 571 571 } … … 575 575 else 576 576 P.muscle_bend_range = 1.0 / std::max(1, dadlink->stickchildcount); //bend range in f1: 0, 1 (line XX[|]) -> 100%, 2 (Y-shape X(X[|],X)) -> 50%, 3 (cross X(X[|],X,X)) -> 33% 577 //MacKo 2023-05: but shouldn't this formula ^^ also take commacount into consideration, like in f1? 578 579 if (type == CELL_STICK)577 //MacKo 2023-05: but shouldn't this formula ^^ also take commacount into consideration, like in f1? Note: in f0, the range of a newly added muscle has the default value (1.0) until modified by mutation, and the range can be set to any value completely unrelated to the junction where the muscle is located. In f1, the range of a newly added muscle depends on the number of branches (commas) in the junction including empty branches (see also conv_f1_f0_branch_muscle_range), but can be overridden by the genotype due to mutation and any value can be directly set just as in f0 - e.g. X[|,r:0.8] - so the value based on the number of commas only serves as a default. Compared to f0 and f1, f4 enforces a specific range here and this cannot be changed in any way, because as of now (2023-05) there is no support to mutate neural properties except for the N neuron. 578 579 if (type == f4_Cell_type::CELL_STICK) 580 580 { 581 581 if (dadlink == NULL) … … 716 716 for (int i = 0; i < cell_count; i++) 717 717 { 718 if (C[i]->type == CELL_NEURON)719 { 720 while (C[i]->dadlink->type == CELL_NEURON)718 if (C[i]->type == f4_Cell_type::CELL_NEURON) 719 { 720 while (C[i]->dadlink->type == f4_Cell_type::CELL_NEURON) 721 721 { 722 722 C[i]->dadlink = C[i]->dadlink->dadlink; … … 729 729 for (int i = 0; i < cell_count; i++) 730 730 { 731 if (C[i]->type == CELL_UNDIFF)732 { 733 C[i]->type = CELL_STICK;731 if (C[i]->type == f4_Cell_type::CELL_UNDIFF) 732 { 733 C[i]->type = f4_Cell_type::CELL_STICK; 734 734 //setError(); 735 735 } … … 764 764 switch (c->type) 765 765 { 766 case CELL_UNDIFF: type = "undiff"; break;767 case CELL_STICK: type = "STICK"; break;768 case CELL_NEURON: type = string("NEURON:") + c->neuclass->name.c_str(); break;769 default: type = std::to_string( c->type);766 case f4_Cell_type::CELL_UNDIFF: type = "undiff"; break; 767 case f4_Cell_type::CELL_STICK: type = "STICK"; break; 768 case f4_Cell_type::CELL_NEURON: type = string("NEURON:") + c->neuclass->name.c_str(); break; 769 default: type = std::to_string(static_cast<int>(c->type)); 770 770 } 771 771 const char *status = c->gcur == c->old_gcur ? (c->gcur != NULL ? "no progress" : "") : (c->gcur != NULL ? "progress" : "finished"); //progress or no progress means the cell is yielding = not finished but decided to halt development and wait for other cells. New cells may be created in case of "no progress" status. … … 893 893 if (curc >= cell_count) return; 894 894 895 if (C[curc]->type != CELL_STICK) return;895 if (C[curc]->type != f4_Cell_type::CELL_STICK) return; 896 896 897 897 f4_Cell *thisti = C[curc]; … … 899 899 *tmpcel = *(thisti->dadlink); 900 900 901 // adjust length, curvedness, etc.901 // Adjust length, curvedness, etc. 902 902 tmpcel->P.propagateAlong(false); 903 904 // The sequence of "while" loops below is a fast and simple heuristic (decrease as long as the value is too big, then increase as long as the value is too small). 905 // However, since every different sequence of upper- and lower-case modifiers produces a different value of a given property, 906 // all 2^N sequences should be tested to discover the best approximation of the target value of a given property using N modifiers. 907 // This issue is TODO if anybody needed this function (and modifier sequences it produces) for any serious use. Also, add support for Qq. 908 // See also GenoOperators::simplifiedModifiers() and geneprops_test.cpp. 903 909 while (tmpcel->P.length > thisti->P.length) 904 910 { … … 938 944 for (int i = 0; i < cell_count; i++) 939 945 { 940 if (C[i]->type == CELL_NEURON)946 if (C[i]->type == f4_Cell_type::CELL_NEURON) 941 947 { 942 948 if (C[i]->dadlink == thisti) … … 971 977 for (int i = 0; i < cell_count; i++) 972 978 { 973 if (C[i]->type == CELL_STICK)979 if (C[i]->type == f4_Cell_type::CELL_STICK) 974 980 { 975 981 if (C[i]->dadlink == thisti)
Note: See TracChangeset
for help on using the changeset viewer.