Changeset 972 for cpp/frams/_demos/multiline_f0_test.cpp
- Timestamp:
- 07/03/20 00:32:23 (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
cpp/frams/_demos/multiline_f0_test.cpp
r955 r972 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-2020 Maciej Komosinski and Szymon Ulatowski. 3 3 // See LICENSE.txt for details. 4 4 … … 13 13 #include <common/virtfile/stringfile.h> 14 14 15 int main(int argc, char*argv[])15 int main(int argc, char*argv[]) 16 16 { 17 LoggerToStdout messages_to_stdout(LoggerBase::Enable);18 PreconfiguredGenetics genetics;17 LoggerToStdout messages_to_stdout(LoggerBase::Enable); 18 PreconfiguredGenetics genetics; 19 19 20 SString gen(argc>1?argv[1]:"X[|G:1.23]");21 if (!strcmp(gen.c_str(),"-"))20 SString gen(argc > 1 ? argv[1] : "X[|G:1.23]"); 21 if (!strcmp(gen.c_str(), "-")) 22 22 { 23 gen=0;24 StdioFILEDontClose in(stdin);25 loadSString(&in,gen);23 gen = 0; 24 StdioFILEDontClose in(stdin); 25 loadSString(&in, gen); 26 26 } 27 Geno g(gen);28 printf("\nSource genotype: '%s'\n",g.getGenes().c_str());29 printf(" ( format %s %s)\n",30 27 Geno g(gen); 28 printf("\nSource genotype: '%s'\n", g.getGenes().c_str()); 29 printf(" ( format %s %s)\n", 30 g.getFormat().c_str(), g.getComment().c_str()); 31 31 32 Model m(g);//.getConverted('0'));32 Model m(g, Model::SHAPE_UNKNOWN);//.getConverted('0')); 33 33 34 if (!m.isValid())34 if (!m.isValid()) 35 35 { 36 printf("Cannot build Model from this genotype!\n");37 return 2;36 printf("Cannot build Model from this genotype!\n"); 37 return 2; 38 38 } 39 printf("Converted to f0:\n%s\n",m.getF0Geno().getGenes().c_str());39 printf("Converted to f0:\n%s\n", m.getF0Geno().getGenes().c_str()); 40 40 41 printf("\nusing Param::saveMultiLine() to create the \"expanded\" form of the f0 genotype...\n(MultiParamLoader should be able to load this)");41 printf("\nusing Param::saveMultiLine() to create the \"expanded\" form of the f0 genotype...\n(MultiParamLoader should be able to load this)"); 42 42 43 StringFILE2 f;43 StringFILE2 f; 44 44 45 static Param modelparam(f0_model_paramtab);46 static Param partparam(f0_part_paramtab);47 static Param jointparam(f0_joint_paramtab);48 static Param neuroparam(f0_neuro_paramtab);49 static Param connparam(f0_neuroconn_paramtab);45 static Param modelparam(f0_model_paramtab); 46 static Param partparam(f0_part_paramtab); 47 static Param jointparam(f0_joint_paramtab); 48 static Param neuroparam(f0_neuro_paramtab); 49 static Param connparam(f0_neuroconn_paramtab); 50 50 51 modelparam.select(&m);52 modelparam.saveMultiLine(&f,"m");51 modelparam.select(&m); 52 modelparam.saveMultiLine(&f, "m"); 53 53 54 Part *p;55 Joint *j;56 Neuro *n;54 Part *p; 55 Joint *j; 56 Neuro *n; 57 57 58 for (int i=0;p=(Part*)m.getPart(i);i++)58 for (int i = 0; p = (Part*)m.getPart(i); i++) 59 59 { 60 partparam.select(p);61 partparam.saveMultiLine(&f,"p");60 partparam.select(p); 61 partparam.saveMultiLine(&f, "p"); 62 62 } 63 for (int i=0;j=(Joint*)m.getJoint(i);i++)63 for (int i = 0; j = (Joint*)m.getJoint(i); i++) 64 64 { 65 jointparam.select(j);66 jointparam.setParamTab(j->usedelta?f0_joint_paramtab:f0_nodeltajoint_paramtab);67 jointparam.saveMultiLine(&f,"j");65 jointparam.select(j); 66 jointparam.setParamTab(j->usedelta ? f0_joint_paramtab : f0_nodeltajoint_paramtab); 67 jointparam.saveMultiLine(&f, "j"); 68 68 } 69 for (int i=0;n=(Neuro*)m.getNeuro(i);i++)69 for (int i = 0; n = (Neuro*)m.getNeuro(i); i++) 70 70 { 71 neuroparam.select(n);72 neuroparam.saveMultiLine(&f,"n");71 neuroparam.select(n); 72 neuroparam.saveMultiLine(&f, "n"); 73 73 } 74 for (int a=0;n=(Neuro*)m.getNeuro(a);a++)74 for (int a = 0; n = (Neuro*)m.getNeuro(a); a++) 75 75 { // inputs 76 for (int b=0;b<n->getInputCount();b++)76 for (int b = 0; b < n->getInputCount(); b++) 77 77 { 78 double w;79 NeuroConn nc;80 Neuro* n2=n->getInput(b,w);81 nc.n1_refno=n->refno; nc.n2_refno=n2->refno;82 nc.weight=w;83 nc.info=n->getInputInfo(b);84 connparam.select(&nc);85 connparam.saveMultiLine(&f,"c");78 double w; 79 NeuroConn nc; 80 Neuro* n2 = n->getInput(b, w); 81 nc.n1_refno = n->refno; nc.n2_refno = n2->refno; 82 nc.weight = w; 83 nc.info = n->getInputInfo(b); 84 connparam.select(&nc); 85 connparam.saveMultiLine(&f, "c"); 86 86 } 87 87 } 88 88 89 printf("\n============================\n%s\n",f.getString().c_str());89 printf("\n============================\n%s\n", f.getString().c_str()); 90 90 91 return 0;91 return 0; 92 92 } 93 93 … … 95 95 96 96 Source genotype: 'X[|G:1.23]' 97 97 ( format 1 ) 98 98 Converted to f0: 99 99 p:
Note: See TracChangeset
for help on using the changeset viewer.