- Timestamp:
- 04/16/21 15:55:34 (4 years ago)
- Location:
- cpp
- Files:
-
- 36 edited
Legend:
- Unmodified
- Added
- Removed
-
cpp/common/2d.h
r1028 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 #define _2D_H_ 7 7 8 #include "nonstd_stl.h"9 8 #include <math.h> 9 #include <algorithm> 10 10 11 11 //unification of old GUIXY and Pt2D … … 58 58 template<> inline bool XY<int>::operator==(const XY<int> &p) const { return (x == p.x) && (y == p.y); } 59 59 60 template <typename T> XY<T> xymin(const XY<T> &a, const XY<T> &b) { return XY<T>( min(a.x, b.x),min(a.y, b.y)); }61 template <typename T> XY<T> xymax(const XY<T> &a, const XY<T> &b) { return XY<T>( max(a.x, b.x),max(a.y, b.y)); }60 template <typename T> XY<T> xymin(const XY<T> &a, const XY<T> &b) { return XY<T>(std::min(a.x, b.x), std::min(a.y, b.y)); } 61 template <typename T> XY<T> xymax(const XY<T> &a, const XY<T> &b) { return XY<T>(std::max(a.x, b.x), std::max(a.y, b.y)); } 62 62 63 63 template <typename T> … … 74 74 T vertical() const { return top + bottom; } 75 75 bool operator==(const XYMargin &other) const { return left == other.left && top == other.top && right == other.right && bottom == other.bottom; } 76 XYMargin normalized() const { return XYMargin( max(left, T(0)), max(top, T(0)), max(right, T(0)),max(bottom, T(0))); }76 XYMargin normalized() const { return XYMargin(std::max(left, T(0)), std::max(top, T(0)), std::max(right, T(0)), std::max(bottom, T(0))); } 77 77 }; 78 78 … … 162 162 } 163 163 164 XYRect fitAspect(float aspect) ///< place a new rectangle having 'aspect' inside the rectangle164 XYRect fitAspect(float aspect) const ///< place a new rectangle having 'aspect' inside the rectangle 165 165 { 166 166 XYRect r; … … 179 179 XY<T> p2 = p + size; 180 180 XY<T> rp2 = r.p + r.size; 181 i.p.x = max(p.x, r.p.x);182 i.p.y = max(p.y, r.p.y);183 i.size.x = min(p2.x, rp2.x) - i.p.x;184 i.size.y = min(p2.y, rp2.y) - i.p.y;181 i.p.x = std::max(p.x, r.p.x); 182 i.p.y = std::max(p.y, r.p.y); 183 i.size.x = std::min(p2.x, rp2.x) - i.p.x; 184 i.size.y = std::min(p2.y, rp2.y) - i.p.y; 185 185 return i; 186 186 } -
cpp/common/Convert.cpp
r1005 r1130 1 1 // This file is a part of Framsticks SDK. http://www.framsticks.com/ 2 // Copyright (C) 1999-20 15Maciej 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 "Convert.h" 6 6 #include <sstream> 7 #include <algorithm> 7 8 8 9 #if defined __ANDROID__ || defined __BORLANDC__ -
cpp/common/log.cpp
r875 r1130 1 1 // This file is a part of Framsticks SDK. http://www.framsticks.com/ 2 // Copyright (C) 1999-20 19Maciej Komosinski and Szymon Ulatowski.2 // Copyright (C) 1999-2021 Maciej Komosinski and Szymon Ulatowski. 3 3 // See LICENSE.txt for details. 4 4 … … 8 8 #include "Convert.h" 9 9 #include <assert.h> 10 #include <algorithm> 10 11 11 12 const char* LOG_LEVEL_ARRAY[] = { "[DEBUG] ", "", "[WARN] ", "[ERROR] ", "[CRITICAL] " }; … … 36 37 { 37 38 assert((level>=LOG_MIN) && (level<=LOG_MAX)); 38 level = min(LOG_MAX,max(LOG_MIN, level));39 level = std::min(LOG_MAX, std::max(LOG_MIN, level)); 39 40 return LOG_LEVEL_ARRAY[level + 1]; 40 41 } -
cpp/common/loggers/loggers.h
r1100 r1130 1 1 // This file is a part of Framsticks SDK. http://www.framsticks.com/ 2 // Copyright (C) 1999-20 19Maciej Komosinski and Szymon Ulatowski.2 // Copyright (C) 1999-2021 Maciej Komosinski and Szymon Ulatowski. 3 3 // See LICENSE.txt for details. 4 4 … … 9 9 #include <common/threads.h> 10 10 #include <common/nonstd_stl.h> 11 #include <algorithm> 11 12 12 13 class LoggerBase; -
cpp/common/loggers/loggertostdout.cpp
r875 r1130 1 1 // This file is a part of Framsticks SDK. http://www.framsticks.com/ 2 // Copyright (C) 1999-20 19Maciej 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 "loggertostdout.h" 6 6 #include <common/console.h> 7 #include <algorithm> 7 8 #include <assert.h> 8 9 #ifdef SHP … … 38 39 { 39 40 assert((level>=LOG_MIN) && (level<=LOG_MAX)); 40 level = min(LOG_MAX,max(LOG_MIN, level));41 level = std::min(LOG_MAX, std::max(LOG_MIN, level)); 41 42 printf(log_format, log_level[level + 1], obj, method, msg, "\n"); 42 43 } -
cpp/common/nonstd_stl.h
r1108 r1130 1 1 // This file is a part of Framsticks SDK. http://www.framsticks.com/ 2 // Copyright (C) 1999-20 15Maciej 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 #define _NONSTD_STL_H_ 7 7 8 // stl jak sama nazwa glosi wcale nie jest nonstd8 //making STL more standard 9 9 10 10 #include <string> 11 11 using std::string; 12 #ifndef SHP // bada nie mawstring12 #ifndef SHP //STL in the bada OS has no wstring 13 13 using std::wstring; 14 14 #endif … … 17 17 using std::vector; 18 18 19 #include <algorithm> //std::min,max,swap20 using std::min;21 using std::max;22 using std::swap;23 19 20 //below: not used since 2020 (these macros are replaced by std::ssize()), may be removed... 24 21 25 22 // ------------------- ARRAY_LENGTH ------------------- 26 23 27 // staromodne makro, niezabezpieczone przed uzyciem wskaznika w roli"x"24 //old-fashioned macro, unprotected against the use of the pointer as "x" 28 25 //#define ARRAY_LENGTH(x) (sizeof(x)/sizeof((x)[0])) 29 26 30 //ha kerskie makro ktore wykrywa czesc pomy³kowych przypadkow uzycia27 //hacker macro that detects some of the misuse cases 31 28 //#define ARRAY_LENGTH(x) ((sizeof(x)/sizeof(0[x])) / ((size_t)(!(sizeof(x) % sizeof(0[x]))))) 32 29 33 // szablonowa funkcja pisana przez sredniozaawansowanych, jak to funkcja - nie daje niestety sta³ej w czasie kompilacji30 //template function by intermediate-level devs, as a function it unfortunately does not give a constant at compile time 34 31 //template<typename T, std::size_t N> inline std::size_t ARRAY_LENGTH( T(&)[N] ) { return N; } //"constexpr" dopiero w C++0x 35 32 36 // szablony hakerskie: tablica bajtow o dlugosci N - tak dluga jak tablica o któr¹ pytamy...33 //hacker templates: array of bytes of length N - as long as the array we are asking for... 37 34 //template <typename T, std::size_t N> 38 35 //char (&array_temp(T (&a)[N]))[N]; … … 44 41 //char (&array_temp(const T (&a)[N]))[N]; 45 42 46 //... ktor¹ mozna potem uzyc normalnie w sizeof i dzieki temu mamy const w compile-time. tak uzyteczne jak staromodne makro ale z pelna kontrola bledow43 //...which can then be used in sizeof and thus we have const in compile-time. This is as useful as the old-fashioned macro above, but with full error control 47 44 //#define ARRAY_LENGTH(x) sizeof(array_temp(x)) 48 45 49 46 //final and no longer needed version ;-) (c++17) 50 #define ARRAY_LENGTH(x) int(std::size(x)) 47 //#define ARRAY_LENGTH(x) int(std::size(x)) 48 //(still room for improvement because unsigned=risky, ssize() upcoming since C++20) 51 49 52 50 -
cpp/common/util-stl.h
r1124 r1130 6 6 #define _UTIL_STL_H_ 7 7 8 #include "nonstd_stl.h"9 8 #include <map> 9 #include <algorithm> 10 10 11 11 template<typename T, std::size_t N> void push_back(vector<T>& v, T(&d)[N]) -
cpp/common/util-string.cpp
r1036 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 … … 9 9 #include <assert.h> 10 10 #include <cstdlib> //malloc() 11 #include <algorithm> 11 12 #ifdef USE_VIRTFILE 12 13 #include <common/virtfile/virtfile.h> -
cpp/frams/_demos/evol_test.cpp
r1031 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 … … 195 195 for (int i = 0; i < nr_evals; i++) 196 196 { 197 int selected_positive = tournament(population, max(2, int(sqrt(population.size()) / 2))); //moderate positive selection pressure197 int selected_positive = tournament(population, std::max(2, int(sqrt(population.size()) / 2))); //moderate positive selection pressure 198 198 int selected_negative = rndUint(population.size()); //random negative selection 199 199 … … 214 214 else 215 215 { 216 int selected_positive2 = tournament(population, max(2, int(sqrt(population.size()) / 2)));216 int selected_positive2 = tournament(population, std::max(2, int(sqrt(population.size()) / 2))); 217 217 Geno xover = genman.crossOver(population[selected_positive].geno, population[selected_positive2].geno); 218 218 if (xover.getGenes() == "") -
cpp/frams/_demos/printconvmap.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 … … 88 88 :model(m) 89 89 { 90 joint_offset = max(10, (int(9 + model.getPartCount()) / 10) * 10);91 neuron_offset = joint_offset + max(10, (int(9 + model.getJointCount()) / 10) * 10);92 max_element = neuron_offset + max(10, (int(9 + model.getNeuroCount()) / 10) * 10);90 joint_offset = std::max(10, (int(9 + model.getPartCount()) / 10) * 10); 91 neuron_offset = joint_offset + std::max(10, (int(9 + model.getJointCount()) / 10) * 10); 92 max_element = neuron_offset + std::max(10, (int(9 + model.getNeuroCount()) / 10) * 10); 93 93 for (int i = 0; i < model.getPartCount(); i++) 94 94 map.add(Model::partToMap(i), Model::partToMap(i), i, i); -
cpp/frams/canvas/neurodiagram.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 … … 13 13 #include <frams/simul/simul.h> 14 14 #include "common/nonstd_time.h" 15 #include <algorithm> 15 16 16 17 #define FIELDSTRUCT NeuroDiagram … … 231 232 NeuroProbe *probe = new NeuroProbe(getNS(i)); 232 233 Pixel s = getSize(); 233 s.x = s.y = max(probe->getSize().x,min(s.x / 3, s.y / 3));234 s.x = s.y = std::max(probe->getSize().x, std::min(s.x / 3, s.y / 3)); 234 235 probes += (void*)probe; 235 236 add(probe); … … 503 504 int *dr = drawing; 504 505 int w = size.x - 2, h = size.y - clienttop - clientbottom; 505 int scale = min(w, h);506 int scale = std::min(w, h); 506 507 int x0 = clienttop + leftborder + ((w > h) ? (w - h) / 2 : 0); 507 508 int y0 = clientleft + topborder + ((h > w) ? (h - w) / 2 : 0); -
cpp/frams/canvas/nn_smart_layout.cpp
r492 r1130 1 1 // This file is a part of Framsticks SDK. http://www.framsticks.com/ 2 // Copyright (C) 1999-20 15Maciej 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 "nn_layout.h" 6 6 #include <vector> 7 #include "common/nonstd_stl.h"7 #include <algorithm> 8 8 #ifdef __BORLANDC__ 9 9 #include <alloc.h> //borland needs for alloc/free … … 131 131 */ 132 132 int x1, y1, x2, y2; // union rectangle 133 x1 = max(0, b2->minx - b->minx + dx);134 x2 = min(b->maxx - b->minx, -b->minx + dx + b2->maxx);133 x1 = std::max(0, b2->minx - b->minx + dx); 134 x2 = std::min(b->maxx - b->minx, -b->minx + dx + b2->maxx); 135 135 if (x1 > x2) return 1; 136 y1 = max(0, b2->miny - b->miny + dy);137 y2 = min(b->maxy - b->miny, -b->miny + dy + b2->maxy);136 y1 = std::max(0, b2->miny - b->miny + dy); 137 y2 = std::min(b->maxy - b->miny, -b->miny + dy + b2->maxy); 138 138 if (y1 > y2) return 1; 139 139 int x, y; … … 162 162 b->dodajelement(e, einfo[e].x + dx, einfo[e].y + dy); 163 163 } 164 b->minx = min(b->minx, dx + b2->minx);165 b->miny = min(b->miny, dy + b2->miny);166 b->maxx = max(b->maxx, dx + b2->maxx);167 b->maxy = max(b->maxy, dy + b2->maxy);164 b->minx = std::min(b->minx, dx + b2->minx); 165 b->miny = std::min(b->miny, dy + b2->miny); 166 b->maxx = std::max(b->maxx, dx + b2->maxx); 167 b->maxy = std::max(b->maxy, dy + b2->maxy); 168 168 169 169 DB( -
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; -
cpp/frams/model/autoname.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 5 5 #include "autoname.h" 6 #include "common/nonstd_stl.h"6 #include <algorithm> 7 7 #include <ctype.h> 8 8 … … 100 100 if (model.getPartCount() > 0) 101 101 { 102 cialo = min((int)(sqrt(double(model.getPartCount()) - 1) * NAME_BODYLEN), NAME_MAXLENBODY - 1);102 cialo = std::min((int)(sqrt(double(model.getPartCount()) - 1) * NAME_BODYLEN), NAME_MAXLENBODY - 1); 103 103 poz = 0; 104 104 for (i = 0; i <= cialo; i++) // budowanie "opisu" ciala … … 106 106 nextpoz = ((model.getPartCount()) * (i + 1)) / (cialo + 1) - 1; 107 107 w = 1.0; 108 for (; poz <= nextpoz; poz++) w = max(w, model.getPart(poz)->mass);109 tmpc[i] = Sp[ min(int((w - 1.0) * NAME_BODYMASS), int(sizeof(Sp)) - 2)];108 for (; poz <= nextpoz; poz++) w = std::max(w, model.getPart(poz)->mass); 109 tmpc[i] = Sp[std::min(int((w - 1.0) * NAME_BODYMASS), int(sizeof(Sp)) - 2)]; 110 110 } 111 111 tmpc[i] = 0; … … 117 117 if (model.getNeuroCount() > 0) 118 118 { 119 mozg = min((int)(sqrt((double)model.getNeuroCount()) * NAME_BRAINLEN), NAME_MAXLENBRAIN - 1);119 mozg = std::min((int)(sqrt((double)model.getNeuroCount()) * NAME_BRAINLEN), NAME_MAXLENBRAIN - 1); 120 120 poz = 0; 121 121 for (i = 0; i <= mozg; i++) // budowanie "opisu" mozgu … … 123 123 nextpoz = (model.getNeuroCount() * (i + 1)) / (mozg + 1) - 1; 124 124 wint = 0; 125 for (; poz <= nextpoz; poz++) wint = max(wint, model.getNeuro(poz)->getInputCount());126 tmpm[i] = Sam[ min(int(wint * NAME_BRAININP), int(sizeof(Sam)) - 2)];125 for (; poz <= nextpoz; poz++) wint = std::max(wint, model.getNeuro(poz)->getInputCount()); 126 tmpm[i] = Sam[std::min(int(wint * NAME_BRAININP), int(sizeof(Sam)) - 2)]; 127 127 } 128 128 tmpm[i] = 0; -
cpp/frams/model/model.h
r1118 r1130 13 13 #include <frams/util/advlist.h> 14 14 #include <frams/util/usertags.h> 15 #include <common/nonstd_stl.h> 15 16 16 17 extern ParamEntry f0_model_paramtab[]; -
cpp/frams/model/similarity/EMD/emd.c
r1064 r1130 19 19 #include <stdlib.h> 20 20 #include <math.h> 21 #include <algorithm> 21 22 22 23 #include "emd.h" … … 100 101 { 101 102 int itr; 102 int max_n = max(_n1, _n2); //max_n was introduced in r1062 instead of the #defined constant MAX_SIG_SIZE1=1000 in the original implementation. max_n is better than the constant, but it would be even better to use either _n1 or _n2, if we only knew what size each individual array should precisely have.103 int max_n = std::max(_n1, _n2); //max_n was introduced in r1062 instead of the #defined constant MAX_SIG_SIZE1=1000 in the original implementation. max_n is better than the constant, but it would be even better to use either _n1 or _n2, if we only knew what size each individual array should precisely have. 103 104 double totalCost; 104 105 float w; … … 211 212 { 212 213 int i, j; 213 int max_n = max(_n1, _n2); //max_n was introduced in r1062 instead of the #defined constant MAX_SIG_SIZE1=1000 in the original implementation. max_n is better than the constant, but it would be even better to use either _n1 or _n2, if we only knew what size each individual array should precisely have.214 int max_n = std::max(_n1, _n2); //max_n was introduced in r1062 instead of the #defined constant MAX_SIG_SIZE1=1000 in the original implementation. max_n is better than the constant, but it would be even better to use either _n1 or _n2, if we only knew what size each individual array should precisely have. 214 215 double sSum, dSum, diff; 215 216 feature_t *P1, *P2; … … 474 475 { 475 476 int i, j, k; 476 int max_n = max(_n1, _n2); //max_n was introduced in r1062 instead of the #defined constant MAX_SIG_SIZE1=1000 in the original implementation. max_n is better than the constant, but it would be even better to use either _n1 or _n2, if we only knew what size each individual array should precisely have.477 int max_n = std::max(_n1, _n2); //max_n was introduced in r1062 instead of the #defined constant MAX_SIG_SIZE1=1000 in the original implementation. max_n is better than the constant, but it would be even better to use either _n1 or _n2, if we only knew what size each individual array should precisely have. 477 478 double xMin; 478 479 int steps; … … 555 556 { 556 557 int i, steps; 557 int max_n = max(_n1, _n2); //max_n was introduced in r1062 instead of the #defined constant MAX_SIG_SIZE1=1000 in the original implementation. max_n is better than the constant, but it would be even better to use either _n1 or _n2, if we only knew what size each individual array should precisely have.558 int max_n = std::max(_n1, _n2); //max_n was introduced in r1062 instead of the #defined constant MAX_SIG_SIZE1=1000 in the original implementation. max_n is better than the constant, but it would be even better to use either _n1 or _n2, if we only knew what size each individual array should precisely have. 558 559 node2_t **CurX, *NewX; 559 560 char *IsUsed=new char[2*max_n]; … … 652 653 { 653 654 int i, j, found, minI, minJ; 654 int max_n = max(_n1, _n2); //max_n was introduced in r1062 instead of the #defined constant MAX_SIG_SIZE1=1000 in the original implementation. max_n is better than the constant, but it would be even better to use either _n1 or _n2, if we only knew what size each individual array should precisely have.655 int max_n = std::max(_n1, _n2); //max_n was introduced in r1062 instead of the #defined constant MAX_SIG_SIZE1=1000 in the original implementation. max_n is better than the constant, but it would be even better to use either _n1 or _n2, if we only knew what size each individual array should precisely have. 655 656 double deltaMin, oldVal, diff; 656 657 double** Delta = new double*[_n1]; -
cpp/frams/model/similarity/measure-distribution.cpp
r1125 r1130 79 79 //int size = sampled.getPartCount(); 80 80 //if (size < (int) sqrt((double) std::numeric_limits<int>::max())) //prevent exceeding int limits 81 // samples_taken = min(samples_num, size*size);81 // samples_taken = std::min(samples_num, size*size); 82 82 83 83 rndgen.seed(55); //For determinism. Otherwise the descriptors (that choose samples pseudo-randomly) for the same Model can yield different values and so the dissimilarity between the object and its copy will not be 0. -
cpp/frams/neuro/impl/neuroimpl-channels.cpp
r907 r1130 1 1 // This file is a part of Framsticks SDK. http://www.framsticks.com/ 2 // Copyright (C) 1999-20 15Maciej 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 "neuroimpl-channels.h" 6 #include < common/nonstd_stl.h>6 #include <algorithm> 7 7 8 8 void NI_Channelize::go() … … 18 18 if (c < 2) { setState(getWeightedInputState(1)); return; } 19 19 double s = getWeightedInputState(0); 20 s = ( max(-1.0,min(1.0, s)) + 1.0) / 2.0; // 0..120 s = (std::max(-1.0, std::min(1.0, s)) + 1.0) / 2.0; // 0..1 21 21 int i1; 22 i1 = (int)(s * (c - 1)); i1 = max(0,min(i1, c - 2));22 i1 = (int)(s * (c - 1)); i1 = std::max(0, std::min(i1, c - 2)); 23 23 double sw = 1.0 / (c - 1); 24 24 double s1 = sw * i1; -
cpp/frams/neuro/impl/neuroimpl-fuzzy-f0.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 8 8 #include "neuroimpl-fuzzy-f0.h" 9 #include < common/nonstd_stl.h> //min,max9 #include <algorithm> 10 10 11 11 //this part concerns fuzzy sets transformation … … 132 132 return -1; 133 133 if ((k >= inNr) && ((k % 2) == 0)) 134 maxOutputNr = max(maxOutputNr, rules[j][k]);134 maxOutputNr = std::max(maxOutputNr, rules[j][k]); 135 135 } 136 136 } -
cpp/frams/neuro/impl/neuroimpl-fuzzy.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 5 5 #include "neuroimpl-fuzzy.h" 6 6 #include "neuroimpl-fuzzy-f0.h" 7 #include <common/nonstd_stl.h> //min,max8 7 9 8 int NI_FuzzyNeuro::countOuts(const Model *m, const Neuro *fuzzy) … … 109 108 nrFuzzySet = rules[i][j * 2 + 1]; // j*2 moves pointer through each output, +1 moves to nr of fuzzy set 110 109 inputNr = rules[i][j * 2]; // as above but gives input number 111 minimumCut = min(minimumCut, TrapeziumFuzz(nrFuzzySet, getWeightedInputState(inputNr))); // value of membership function for this input and given fuzzy set110 minimumCut = std::min(minimumCut, TrapeziumFuzz(nrFuzzySet, getWeightedInputState(inputNr))); // value of membership function for this input and given fuzzy set 112 111 } 113 112 if ((minimumCut > 1) || (minimumCut < 0)) -
cpp/frams/param/mutableparam.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 … … 22 22 }; 23 23 #undef FIELDSTRUCT 24 const int MutableParam::staticprops = ARRAY_LENGTH(pe_tab);24 const int MutableParam::staticprops = std::size(pe_tab); 25 25 26 26 MutableParam::MutableParam(const char*n, const char*g, int gr0) -
cpp/frams/param/paramobj.cpp
r1051 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/param/paramobj.h> 6 6 #include <frams/util/extvalue.h> 7 #include < common/nonstd_stl.h>7 #include <algorithm> 8 8 9 9 static const char* maybedup(bool dup, const char* src) … … 232 232 const ExtValue *s = &src.fields[0]; 233 233 ExtValue *d = &fields[0]; 234 int n = min(numfields, src.numfields);234 int n = std::min(numfields, src.numfields); 235 235 for (int i = 0; i < n; i++, d++, s++) 236 236 *d = *s; -
cpp/frams/util/extvalue.h
r851 r1130 1 1 // This file is a part of Framsticks SDK. http://www.framsticks.com/ 2 // Copyright (C) 1999-20 15Maciej Komosinski and Szymon Ulatowski.2 // Copyright (C) 1999-2021 Maciej Komosinski and Szymon Ulatowski. 3 3 // See LICENSE.txt for details. 4 4 … … 8 8 #include "sstring.h" 9 9 #include <frams/param/param.h> 10 #include <common/nonstd_stl.h>11 10 #include <common/threads.h> 11 #include <vector> 12 12 13 13 #define EXTVALUEUNION -
cpp/frams/util/multirange.cpp
r733 r1130 1 1 // This file is a part of Framsticks SDK. http://www.framsticks.com/ 2 // Copyright (C) 1999-20 15Maciej 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 "multirange.h" 6 #include < common/nonstd_stl.h>6 #include <algorithm> 7 7 8 8 #include <stdio.h> … … 230 230 break; 231 231 case SAME + JOINBEGIN: // extend 1 range 232 setEnd(r1, max(getEnd(r2), end));232 setEnd(r1, std::max(getEnd(r2), end)); 233 233 break; 234 234 case SAME + JOINEND: // extend 1 range … … 244 244 break; 245 245 case JOINBEGIN: // extend r1 246 setEnd(r1, max(end, getEnd(r2)));246 setEnd(r1, std::max(end, getEnd(r2))); 247 247 removeRanges(r1 + 1, r2); 248 248 break; … … 253 253 case 0: // extend r2 254 254 setBegin(r2, begin); 255 setEnd(r2, max(end, getEnd(r2)));255 setEnd(r2, std::max(end, getEnd(r2))); 256 256 removeRanges(r1 + 1, r2 - 1); 257 257 break; -
cpp/frams/util/sstring-simple.cpp
r1040 r1130 1 1 #include "sstring.h" 2 #include <common/nonstd_stl.h>3 2 #include "extvalue.h" 4 3 #include <assert.h> -
cpp/frams/util/sstring.cpp
r1040 r1130 20 20 // - mutex required to be thread safe 21 21 22 #include <common/nonstd_stl.h>23 22 #include "extvalue.h" 24 23 #include <assert.h> -
cpp/frams/vm/classes/collectionobj.cpp
r1076 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 <common/nonstd_math.h> //sqrt in borland 7 7 #include <frams/util/validitychecks.h> 8 #include < common/nonstd_stl.h>8 #include <algorithm> 9 9 #include <frams/util/sstringutils.h> 10 10 #ifndef NO_VMACHINE … … 228 228 s += d * d; 229 229 } 230 ret->setDouble(sqrt(s / max(1, data.size() - 1)));230 ret->setDouble(sqrt(s / std::max(1, data.size() - 1))); 231 231 } 232 232
Note: See TracChangeset
for help on using the changeset viewer.