Changeset 1274
- Timestamp:
- 09/09/23 15:12:57 (14 months ago)
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
cpp/common/2d.h
r1130 r1274 1 1 // This file is a part of Framsticks SDK. http://www.framsticks.com/ 2 // Copyright (C) 1999-202 1Maciej 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 <algorithm> 10 10 11 //unification of old GUIXY and Pt2D12 11 template <typename T> class XY 13 12 { … … 174 173 } 175 174 175 XYRect fillAspect(float aspect) 176 { 177 XYRect r; 178 r.size = size; 179 if (size.x < size.y * aspect) 180 r.size.x = r.size.y * aspect; 181 else 182 r.size.y = r.size.x / aspect; 183 r.p = p + (size - r.size) * 0.5; 184 return r; 185 } 186 176 187 XYRect intersection(const XYRect &r) const 177 188 { -
cpp/common/Convert.cpp
r1130 r1274 155 155 wstring wstr; 156 156 int nOffset = 0; 157 int nDataLen = strlen(str); //ending \0 is not converted, but resize() below sets the proper length of wstr157 int nDataLen = (int)strlen(str); //ending \0 is not converted, but resize() below sets the proper length of wstr 158 158 int nLenWide = MultiByteToWideChar(CP_UTF8, 0, (LPCSTR)(str + nOffset), 159 159 (int)(nDataLen - nOffset), NULL, 0); -
cpp/frams/genetics/f4/f4_conv.cpp
r1259 r1274 247 247 { 248 248 const char* nclass = C->neuclass->name.c_str(); 249 if (C->neuclass->getPreferredLocation() == 0) 249 switch (C->neuclass->getPreferredLocation()) 250 { 251 case NeuroClass::PrefLocation::PREFER_UNATTACHED: 250 252 { 251 253 if (strcmp(nclass, "N") == 0) //special case just to specify the only neuron properties supported by f4, i.e., the properties for neuron class 'N' … … 253 255 else 254 256 sprintf(tmpLine, "d=\"%s\"", nclass); 255 } 256 else if (C->neuclass->getPreferredLocation() == 1) // attached to Part or have no required attachment - also part 257 break; 258 } 259 case NeuroClass::PrefLocation::PREFER_PART: // attach to Part 257 260 { 258 261 int partno = C->dadlink->p2_refno; … … 260 263 261 264 sprintf(tmpLine, "p=%d,d=\"%s\"", partno, nclass); 262 } 263 else // attached to Joint, assume there are only three possibilities of getPreferredLocation() 265 break; 266 } 267 case NeuroClass::PrefLocation::PREFER_JOINT: // attach to Joint 264 268 { 265 269 int jointno = C->dadlink->joint_refno; … … 273 277 else 274 278 sprintf(tmpLine, "j=%d,d=\"%s\"", jointno, nclass); 279 break; 280 } 275 281 } 276 282 -
cpp/frams/genetics/f4/f4_oper.cpp
r1259 r1274 8 8 9 9 10 // This representation has a tendency to bloat - adding a small penalty to fitness such as "this.velocity - 0.000000001*String.len(this.genotype);" 11 // may help, but it would be better to improve the source code to make genetic operators neutral in terms of genotype length. Adding such a penalty 12 // removes "work in progress" changes in genotypes thus promoting immediate, straightforward improvements while hindering slower, multifaceted progress. 10 // This representation has a tendency to bloat - adding a small penalty to fitness such as "this.velocity - 0.000000001*String.len(this.genotype);" may help, but it would be better to improve the source code to make genetic operators neutral in terms of genotype length. Adding such a penalty removes "work in progress" changes in genotypes thus promoting immediate, straightforward improvements while hindering slower, multifaceted progress. 13 11 // TODO getting rid of redundancy (valid genotypes with a lot of "junk code") in this representation looks like a good idea; many improvements to this end have already been done in April & May 2023, so maybe it is not a big problem now? 14 // 12 // 15 13 // 16 14 // TODO the behavior of neuron input indexes during mutation seems badly implemented (see also TREAT_BAD_CONNECTIONS_AS_INVALID_GENO). Are they kept properly maintained when nodes are added and removed? This could be done well because during mutation we operate on the tree structure with cross-references between nodes (so they should not be affected by local changes in the tree), and then convert the tree back to string. Yet, the f4_Node.conn_from is an integer and these fields in nodes do not seem to be maintained on tree node adding/removal... change these integer offsets to references to node objects? But actually, do the offsets that constitute relative connection references concern the f4_Node tree structure (and all these sophisticated calculations of offsets during mutation are useful) or rather they concern the f4_Cells development? verify all situations in f4_Cell::oneStep(), case '['. -
cpp/frams/genetics/f9/f9_oper.cpp
r1216 r1274 124 124 { 125 125 int len1 = (int)strlen(g1), len2 = (int)strlen(g2); 126 int p1 = rndUint(len1); //random cut point for first genotype127 int p2 = rndUint(len2); //random cut point for second genotype126 int p1 = rndUint(len1); //random cut point for the first genotype 127 int p2 = rndUint(len2); //random cut point for the second genotype 128 128 char *child1 = (char*)malloc(p1 + len2 - p2 + 1); 129 129 char *child2 = (char*)malloc(p2 + len1 - p1 + 1); … … 147 147 int pos = ptr - turtle_commands_f9; 148 148 int axis = pos / 2; 149 style = GENSTYLE_RGBS(axis == 0 ? 200 : 0, axis == 1 ? 200 : 0, axis == 2? 200 : 0, GENSTYLE_NONE);149 style = GENSTYLE_RGBS(axis == 0 ? 200 : 0, axis == 2 ? 200 : 0, axis == 1 ? 200 : 0, GENSTYLE_NONE); 150 150 } 151 151 return style; -
framspy/eval-allcriteria.sim
r1162 r1274 75 75 genoper_f0s:0 76 76 genoper_f1:0 77 genoper_f2:078 genoper_f3:079 77 genoper_f4:0 80 78 genoper_f8:0 … … 183 181 f1_nmWei:1.0 184 182 f1_nmVal:0.05 185 f2_mutAddOper:0.4186 f2_mutJointElem:0.33187 f2_mutNeuroElem:0.33188 f2_mutConnElem:0.33189 f2_mutDelOper:0.1190 f2_mutHandleOper:0.3191 f2_mutPropOper:0.2192 f3_mutSubstitution:0.6193 f3_mutSubstPerChar:0.1194 f3_mutDelIns:0.1195 f3_mutDelInsPerChar:0.05196 f3_mutDelInsLength:5197 f3_mutDuplication:0.05198 f3_mutTranslocation:0.15199 f3_xovGeneTransfer:0.8200 f3_xovCrossingOver:0.2201 183 f4_mut_add:50.0 202 184 f4_mut_add_div:20.0
Note: See TracChangeset
for help on using the changeset viewer.