Changeset 797 for cpp/frams/genetics/fH
- Timestamp:
- 06/06/18 01:45:18 (7 years ago)
- Location:
- cpp/frams/genetics/fH
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
cpp/frams/genetics/fH/fH_conv.cpp
r780 r797 1 // This file is a part of Framsticks SDK. http://www.framsticks.com/ 2 // Copyright (C) 1999-2018 Maciej Komosinski and Szymon Ulatowski. 3 // See LICENSE.txt for details. 4 1 5 #include "fH_conv.h" 2 6 -
cpp/frams/genetics/fH/fH_conv.h
r780 r797 1 // This file is a part of Framsticks SDK. http://www.framsticks.com/ 2 // Copyright (C) 1999-2018 Maciej Komosinski and Szymon Ulatowski. 3 // See LICENSE.txt for details. 4 1 5 #ifndef _FH_CONV_H_ 2 6 #define _FH_CONV_H_ -
cpp/frams/genetics/fH/fH_general.cpp
r780 r797 1 // This file is a part of Framsticks SDK. http://www.framsticks.com/ 2 // Copyright (C) 1999-2018 Maciej Komosinski and Szymon Ulatowski. 3 // See LICENSE.txt for details. 4 1 5 #include <string> 2 6 #include <limits> … … 13 17 // Methods for loading handles 14 18 15 const char *fH_part_names[ PART_PROPS_COUNT] = { "dn", "fr", "ing", "as" };16 17 const char *fH_joint_names[ JOINT_PROPS_COUNT] = { "stif", "rotstif", "stam" };19 const char *fH_part_names[FH_PART_PROPS_COUNT] = { "dn", "fr", "ing", "as" }; 20 21 const char *fH_joint_names[FH_JOINT_PROPS_COUNT] = { "stif", "rotstif", "stam" }; 18 22 19 23 void fH_Handle::loadProperties(Param par) … … 106 110 107 111 Part p; 108 for (int i = 0; i < PART_PROPS_COUNT; i++)112 for (int i = 0; i < FH_PART_PROPS_COUNT; i++) 109 113 { 110 114 stickmut.addProperty(&p.properties().getParamTab()[p.properties().findId(fH_part_names[i]) + p.properties().getGroupCount()], -1); … … 112 116 113 117 Joint j; 114 for (int i = 0; i < JOINT_PROPS_COUNT; i++)118 for (int i = 0; i < FH_JOINT_PROPS_COUNT; i++) 115 119 { 116 120 stickmut.addProperty(&j.properties().getParamTab()[j.properties().findId(fH_joint_names[i]) + j.properties().getGroupCount()], -1); … … 119 123 120 124 Neuro n; 121 neuronmut.addProperty(&n.properties().getParamTab()[n.properties().findId( PE_NEURO_DET) + n.properties().getGroupCount()], -1);125 neuronmut.addProperty(&n.properties().getParamTab()[n.properties().findId(FH_PE_NEURO_DET) + n.properties().getGroupCount()], -1); 122 126 123 127 Param tmp(f0_neuroconn_paramtab, NULL); 124 connectionmut.addProperty(&tmp.getParamTab()[tmp.findId( PE_CONN_WEIGHT) + tmp.getGroupCount()], -1);128 connectionmut.addProperty(&tmp.getParamTab()[tmp.findId(FH_PE_CONN_WEIGHT) + tmp.getGroupCount()], -1); 125 129 126 130 stickparamtab = ParamObject::makeParamTab((ParamInterface *)&stickmut, 0, 0, stickmut.firstMutableIndex()); … … 343 347 { 344 348 Param par(tab, obj); 345 double partprops[ PART_PROPS_COUNT];346 for (int i = 0; i < PART_PROPS_COUNT; i++)349 double partprops[FH_PART_PROPS_COUNT]; 350 for (int i = 0; i < FH_PART_PROPS_COUNT; i++) 347 351 { 348 352 partprops[i] = par.getDouble(2 * getDimensions() + i); … … 357 361 { 358 362 par.select(child->obj); 359 for (int i = 0; i < PART_PROPS_COUNT; i++)363 for (int i = 0; i < FH_PART_PROPS_COUNT; i++) 360 364 { 361 365 partprops[i] += par.getDouble(2 * getDimensions() + i); … … 364 368 } 365 369 366 for (int i = 0; i < PART_PROPS_COUNT; i++)370 for (int i = 0; i < FH_PART_PROPS_COUNT; i++) 367 371 { 368 372 partprops[i] /= stickscount; … … 522 526 msg += det + "\" does not exist"; 523 527 logMessage("fH_Builder", "developBrain", LOG_ERROR, msg.c_str()); 528 delete currneu->neuron; 524 529 return -1; 525 530 } … … 601 606 if (!beginneu) 602 607 { 603 logMessage("fH_Builder", "developBrain", LOG_WARN, "There are no available neurons with outputs, connection could not be established"); 608 // due to often appearance of connection genes in fB encoding, this 609 // log message is commented 610 // logMessage("fH_Builder", "developBrain", LOG_DEBUG, "There are no available neurons with outputs, connection could not be established"); 604 611 continue; 605 612 } … … 628 635 if (!endneu) 629 636 { 630 logMessage("fH_Builder", "developBrain", LOG_WARN, "There are no available neurons with free inputs, connection could not be established"); 637 // due to often appearance of connection genes in fB encoding, this 638 // log message is commented 639 // logMessage("fH_Builder", "developBrain", LOG_DEBUG, "There are no available neurons with free inputs, connection could not be established"); 631 640 continue; 632 641 } -
cpp/frams/genetics/fH/fH_general.h
r780 r797 1 // This file is a part of Framsticks SDK. http://www.framsticks.com/ 2 // Copyright (C) 1999-2018 Maciej Komosinski and Szymon Ulatowski. 3 // See LICENSE.txt for details. 4 1 5 #ifndef _FH_GENERAL_H_ 2 6 #define _FH_GENERAL_H_ … … 14 18 #define HANDLE_VECTOR_TYPE "f -1.0 1.0 0.0" ///<Vector values type definition 15 19 #define STICKH_LENGTH_TYPE "f 0.001 1.999 1.0" ///<Length of stick handle. Minimum should not be equal to 0, because calculating direction of next part from current stick with length 0 would be impossible 16 #define PART_PROPS_COUNT 4 ///<Count of part properties17 #define JOINT_PROPS_COUNT 3 ///<Count of joint properties18 #define PE_NEURO_DET "d" ///<Id of details type definition in f0_neuro_paramtab19 #define PE_CONN_WEIGHT "w" ///<Id of weight type definition in f0_neuroconn_paramtab20 #define FH_PART_PROPS_COUNT 4 ///<Count of part properties 21 #define FH_JOINT_PROPS_COUNT 3 ///<Count of joint properties 22 #define FH_PE_NEURO_DET "d" ///<Id of details type definition in f0_neuro_paramtab 23 #define FH_PE_CONN_WEIGHT "w" ///<Id of weight type definition in f0_neuroconn_paramtab 20 24 //@} 21 25 -
cpp/frams/genetics/fH/fH_oper.cpp
r780 r797 1 // This file is a part of Framsticks SDK. http://www.framsticks.com/ 2 // Copyright (C) 1999-2018 Maciej Komosinski and Szymon Ulatowski. 3 // See LICENSE.txt for details. 4 1 5 #include "fH_oper.h" 2 6 … … 421 425 } 422 426 423 void Geno_fH::mutateNeuron HandleProperties(fH_NeuronHandle *handle, ParamEntry *tab, bool userandomclass)427 void Geno_fH::mutateNeuronProperties(SString &det) 424 428 { 425 429 Neuro neu; 426 Param hpar(tab, handle->obj); 427 SString det = hpar.getStringById("d"); 430 det = det == "" ? "N" : det; 428 431 neu.setDetails(det == "" ? "N" : det); 429 NeuroClass *nc = neu.getClass();430 431 if (userandomclass)432 {433 nc = getRandomNeuroClass();434 if (!nc) nc = Neuro::getClass("N");435 }436 437 det = nc->getName();438 neu.setDetails(det);439 432 440 433 SyntParam par = neu.classProperties(); … … 455 448 if (props != "") 456 449 { 450 det = neu.getClass()->name; 457 451 det += ": "; 458 452 det += props; 459 hpar.setStringById("d", det); 460 } 461 } 462 } 463 464 uint32_t Geno_fH::style(const char *geno, int pos) 465 { 466 char ch = geno[pos]; 467 uint32_t style = GENSTYLE_CS(0, GENSTYLE_STRIKEOUT); 468 if (pos == 0 || geno[pos - 1] == '\n' || ch == ':') // single-character handle type and all colons 469 { 470 style = GENSTYLE_CS(GENCOLOR_TEXT, GENSTYLE_BOLD); 471 } 472 else if (isalpha(ch)) // properties name 473 { 474 style = GENSTYLE_RGBS(0, 200, 0, GENSTYLE_BOLD); 475 } 476 else if (isdigit(ch) || strchr(",.=", ch)) // properties values 477 { 478 style = GENSTYLE_CS(GENCOLOR_TEXT, GENSTYLE_NONE); 479 } 480 else if (ch == '\"') 481 { 482 style = GENSTYLE_RGBS(200, 0, 0, GENSTYLE_BOLD); 483 } 484 485 return style; 486 } 453 } 454 } 455 } 456 457 void Geno_fH::mutateNeuronHandleProperties(fH_NeuronHandle *handle, ParamEntry *tab, bool userandomclass) 458 { 459 Neuro neu; 460 Param hpar(tab, handle->obj); 461 SString det = hpar.getStringById("d"); 462 neu.setDetails(det == "" ? "N" : det); 463 NeuroClass *nc = neu.getClass(); 464 465 if (userandomclass) 466 { 467 nc = getRandomNeuroClass(); 468 if (!nc) nc = Neuro::getClass("N"); 469 } 470 471 det = nc->getName(); 472 473 mutateNeuronProperties(det); 474 475 hpar.setStringById("d", det); 476 } 477 478 //uint32_t Geno_fH::style(const char *geno, int pos) 479 //{ 480 // char ch = geno[pos]; 481 // uint32_t style = GENSTYLE_CS(0, GENSTYLE_STRIKEOUT); 482 // if (pos == 0 || geno[pos - 1] == '\n' || ch == ':') // single-character handle type and all colons 483 // { 484 // style = GENSTYLE_CS(GENCOLOR_TEXT, GENSTYLE_BOLD); 485 // } 486 // else if (isalpha(ch)) // properties name 487 // { 488 // style = GENSTYLE_RGBS(0, 200, 0, GENSTYLE_BOLD); 489 // } 490 // else if (isdigit(ch) || strchr(",.=", ch)) // properties values 491 // { 492 // style = GENSTYLE_CS(GENCOLOR_TEXT, GENSTYLE_NONE); 493 // } 494 // else if (ch == '\"') 495 // { 496 // style = GENSTYLE_RGBS(200, 0, 0, GENSTYLE_BOLD); 497 // } 498 // 499 // return style; 500 //} 501 502 uint32_t Geno_fH::style(const char *g, int pos) 503 { 504 char ch=g[pos]; 505 uint32_t style=GENSTYLE_CS(0,GENSTYLE_NONE); //default, should be changed below 506 507 int pp=pos; //detect comment line 508 while (pp>1 && g[pp-1]!='\n') pp--; 509 if (g[pp]=='#') return GENSTYLE_RGBS(0,220,0,GENSTYLE_NONE); //comment line 510 511 if (pos==0 || g[pos-1]=='\n' || ch==':' || ch==',') style=GENSTYLE_CS(0,GENSTYLE_BOLD); else 512 if (ch=='\"') style=GENSTYLE_RGBS(150,0,0,GENSTYLE_BOLD); else 513 { 514 int cudz=0,neuclass=1; //ile cudz. do poczatku linii; czy w nazwie neuroklasy? 515 while (pos>0) 516 { 517 pos--; 518 if (g[pos]=='\"') cudz++; 519 if (cudz==0 && (g[pos]==':' || g[pos]==',')) neuclass=0; 520 if (g[pos]=='\n') break; 521 } 522 if (cudz%2) 523 { 524 if (neuclass) style=GENSTYLE_RGBS(150,0,150,GENSTYLE_BOLD); else //neuroclass 525 if (isalpha(ch)) style=GENSTYLE_RGBS(255,140,0,GENSTYLE_BOLD); else //property 526 style=GENSTYLE_RGBS(200,0,0,GENSTYLE_NONE); 527 } else 528 if (isalpha(ch)) style=GENSTYLE_RGBS(0,0,200,GENSTYLE_BOLD); 529 } 530 return style; 531 } -
cpp/frams/genetics/fH/fH_oper.h
r780 r797 1 // This file is a part of Framsticks SDK. http://www.framsticks.com/ 2 // Copyright (C) 1999-2018 Maciej Komosinski and Szymon Ulatowski. 3 // See LICENSE.txt for details. 4 1 5 #ifndef _FH_OPER_H_ 2 6 #define _FH_OPER_H_ … … 87 91 double addoperations[FH_ADD_OPCOUNT]; ///<relative probabilities of selecting mutation addition subtypes 88 92 93 // TODO add to GenoOperators? 94 /** 95 * Mutates properties of neuron and returns full neuron class description. 96 * @param det current neuron class definition with its parameters 97 */ 98 static void mutateNeuronProperties(SString &det); 99 89 100 Geno_fH(); 90 101
Note: See TracChangeset
for help on using the changeset viewer.