Changeset 1130 for cpp/frams/genetics
- Timestamp:
- 04/16/21 15:55:34 (4 years ago)
- Location:
- cpp/frams/genetics
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
cpp/frams/genetics/f1/f1_conv.cpp
r1039 r1130 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-2021 Maciej Komosinski and Szymon Ulatowski. 3 3 // See LICENSE.txt for details. 4 4 5 5 #include "f1_conv.h" 6 #include <common/nonstd_stl.h>7 6 #include <common/log.h> 8 7 #include <frams/util/multirange.h> … … 11 10 #include <ctype.h> 12 11 #include <assert.h> 12 #include <algorithm> 13 13 14 14 //#define v1f1COMPATIBLE //as in ancient Framsticks 1.x … … 273 273 int Builder::growJoint(int part1, int part2, Pt3D &angle, GeneProps &c, const char *g) 274 274 { 275 double len = min(2.0, c.length);275 double len = std::min(2.0, c.length); 276 276 sprintf(tmp, "p1=%d,p2=%d,dx=%lg,rx=%lg,ry=%lg,rz=%lg,stam=%lg,vr=%g,vg=%g,vb=%g", 277 277 part1, part2, len, angle.x, angle.y, angle.z, c.stamina, c.cred, c.cgreen, c.cblue); -
cpp/frams/genetics/f9/f9_conv.cpp
r1108 r1130 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-2021 Maciej Komosinski and Szymon Ulatowski. 3 3 // See LICENSE.txt for details. 4 4 … … 6 6 #include <frams/model/model.h> 7 7 #include <string.h> 8 #include <common/nonstd_stl.h> //ARRAY_LENGTH9 8 10 9 #define APPLY_DETERMINISTIC_BODY_NOISE //this genetic representation easily produces perfectly vertical sticks that would stay upright forever in simulation. In most cases such infinite perfection is not desired, so we make the construct less perfect by perturbing its coordinates. … … 129 128 static int g[] = { 0, 1, 1, 1, 0, 0 }; 130 129 static int b[] = { 0, 0, 0, 1, 1, 1 }; 131 int maxind = ARRAY_LENGTH(r) - 1;130 int maxind = int(std::size(r)) - 1; 132 131 133 132 int joints_count = m.getJointCount(); -
cpp/frams/genetics/fB/fB_conv.cpp
r973 r1130 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-2021 Maciej Komosinski and Szymon Ulatowski. 3 3 // See LICENSE.txt for details. 4 4 … … 7 7 #include <frams/param/paramobj.h> 8 8 #include <vector> 9 #include <algorithm> 9 10 #include <frams/util/multimap.h> 10 11 #include "fB_general.h" … … 250 251 double mn, mx, def; 251 252 par.getMinMaxDouble(propindex, mn, mx, def); 252 par.setDouble(propindex, min(mx,max(mn, (mx - mn) * val + mn)));253 par.setDouble(propindex, std::min(mx, std::max(mn, (mx - mn) * val + mn))); 253 254 } 254 255 propindex++; -
cpp/frams/genetics/fB/fB_oper.cpp
r999 r1130 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-2021 Maciej Komosinski and Szymon Ulatowski. 3 3 // See LICENSE.txt for details. 4 4 5 5 #include <frams/util/sstring.h> 6 6 #include <vector> 7 #include <algorithm> 7 8 #include <frams/param/param.h> 8 9 #include "fB_conv.h" … … 461 462 { 462 463 // get maximal count of genes from both parents 463 int maxgenecount = max(fB_GenoHelpers::geneCountNoNested(parent1),464 int maxgenecount = std::max(fB_GenoHelpers::geneCountNoNested(parent1), 464 465 fB_GenoHelpers::geneCountNoNested(parent2)); 465 466 -
cpp/frams/genetics/fF/fF_conv.cpp
r994 r1130 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-2021 Maciej Komosinski and Szymon Ulatowski. 3 3 // See LICENSE.txt for details. 4 4 5 5 #include "fF_conv.h" 6 6 #include "fF_genotype.h" 7 #include <common/nonstd_stl.h>8 7 #include <common/Convert.h> 9 8 -
cpp/frams/genetics/fF/fF_oper.cpp
r974 r1130 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-2021 Maciej Komosinski and Szymon Ulatowski. 3 3 // See LICENSE.txt for details. 4 4 … … 49 49 par.load(gene); 50 50 static const int propsToMutate[] = fF_PROPS_TO_MUTATE; 51 int which = rndUint( ARRAY_LENGTH(propsToMutate));51 int which = rndUint(std::size(propsToMutate)); 52 52 bool mutated_ok = GenoOperators::mutatePropertyNaive(par.param, propsToMutate[which]); 53 53 if (mutated_ok) -
cpp/frams/genetics/fS/fS_general.cpp
r1108 r1130 1 1 // This file is a part of Framsticks SDK. http://www.framsticks.com/ 2 // Copyright (C) 2019-202 0Maciej Komosinski and Szymon Ulatowski.2 // Copyright (C) 2019-2021 Maciej Komosinski and Szymon Ulatowski. 3 3 // See LICENSE.txt for details. 4 4 … … 13 13 #include "common/nonstd_math.h" 14 14 #include <frams/model/geometry/part_distance_estimator.h> 15 #include <algorithm> 15 16 16 17 int fS_Genotype::precision = 4; -
cpp/frams/genetics/fS/fS_oper.cpp
r1056 r1130 1 1 // This file is a part of Framsticks SDK. http://www.framsticks.com/ 2 // Copyright (C) 2019-202 0Maciej Komosinski and Szymon Ulatowski.2 // Copyright (C) 2019-2021 Maciej Komosinski and Szymon Ulatowski. 3 3 // See LICENSE.txt for details. 4 4 … … 7 7 #include "fS_oper.h" 8 8 #include "frams/util/rndutil.h" 9 #include <algorithm> 9 10 10 11 #define FIELDSTRUCT GenoOper_fS … … 362 363 { 363 364 // Remove the selected child 364 s wap(randomNode->children[selectedIndex], randomNode->children[childCount - 1]);365 std::swap(randomNode->children[selectedIndex], randomNode->children[childCount - 1]); 365 366 randomNode->children.pop_back(); 366 367 randomNode->children.shrink_to_fit(); … … 586 587 fS_Neuron *it = randomNode->neurons[rndUint(size)]; 587 588 geno.rearrangeNeuronConnections(it, SHIFT::LEFT); // Important to rearrange the neurons before deleting 588 s wap(it, randomNode->neurons.back());589 std::swap(it, randomNode->neurons.back()); 589 590 randomNode->neurons.pop_back(); 590 591 randomNode->neurons.shrink_to_fit(); -
cpp/frams/genetics/fn/fn_conv.h
r779 r1130 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-2021 Maciej Komosinski and Szymon Ulatowski. 3 3 // See LICENSE.txt for details. 4 4 … … 7 7 8 8 #include <frams/genetics/genoconv.h> 9 #include <common/nonstd_stl.h> 9 10 10 11 // The fn->f0 converter -
cpp/frams/genetics/geneprops.cpp
r1039 r1130 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-2021 Maciej Komosinski and Szymon Ulatowski. 3 3 // See LICENSE.txt for details. 4 4 5 5 #include "geneprops.h" 6 #include <algorithm> 6 7 7 8 GeneProps GeneProps::standard_values; … … 54 55 #ifdef v1f1COMPATIBLE 55 56 case 'L': length += (3.0 - length)*0.3; 56 length = min(length, Model::getMaxJoint().d.x); break;57 length = std::min(length, Model::getMaxJoint().d.x); break; 57 58 #else 58 59 case 'L': length += (2.0 - length)*0.3; //2.0 is currently Model::getMaxJoint().d.x so min() does not limit the range 59 length = min(length, Model::getMaxJoint().d.x); break;60 length = std::min(length, Model::getMaxJoint().d.x); break; 60 61 #endif 61 62 case 'l': length += (0.33 - length)*0.3; 62 length = max(length, Model::getMinJoint().d.x); break;63 length = std::max(length, Model::getMinJoint().d.x); break; 63 64 64 65 case 'W': weight += (2.0 - weight)*0.3; break;
Note: See TracChangeset
for help on using the changeset viewer.