Changeset 348 for cpp/frams/_demos/genomanipulation.cpp
- Timestamp:
- 04/09/15 23:51:28 (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
cpp/frams/_demos/genomanipulation.cpp
r291 r348 34 34 const char* type=pi.type(i); 35 35 if (*type=='p') continue; 36 printf("%2d. %8s = %-20s %-3s %-10s %-10s\n",i,pi.id(i), (const char*)pi.get(i),pi.type(i),pi.name(i),pi.grname(pi.group(i)));36 printf("%2d. %8s = %-20s %-3s %-10s %-10s\n",i,pi.id(i),pi.get(i).c_str(),pi.type(i),pi.name(i),pi.grname(pi.group(i))); 37 37 } 38 38 } … … 47 47 pi.getMinMax(i,minprop,maxprop,def); 48 48 printf(" Change property #%d to random value from range [%g..%g]\n",i,minprop,maxprop); 49 printf(" Current value of '%s' (%s) is '%s'\n",pi.id(i),pi.name(i), (const char*)pi.get(i));49 printf(" Current value of '%s' (%s) is '%s'\n",pi.id(i),pi.name(i),pi.get(i).c_str()); 50 50 char t[100]; 51 51 sprintf(t,"%g",minprop+(rnd01)*(maxprop-minprop)); 52 52 printf(" Setting new value... [ using ParamInterface::set() ]\n"); 53 53 pi.set(i,t); 54 printf(" The value is now '%s'\n", (const char*)pi.get(i));54 printf(" The value is now '%s'\n",pi.get(i).c_str()); 55 55 } 56 56 … … 79 79 CHANGE_ONE_PROPERTY(p->extraProperties()); 80 80 p->getModel().close(); 81 printf("\nLet's see f0... (check out part #%d !)\n\n%s\n", p->refno, (const char*)p->getModel().getF0Geno().getGene());81 printf("\nLet's see f0... (check out part #%d !)\n\n%s\n", p->refno, p->getModel().getF0Geno().getGene().c_str()); 82 82 } 83 83 … … 91 91 j->getModel().close(); 92 92 printf("The Part's position is changed, but everything else stays intact:\n\n%s\n", 93 (const char*)j->getModel().getF0Geno().getGene());93 j->getModel().getF0Geno().getGene().c_str()); 94 94 } 95 95 … … 104 104 j->getModel().close(); 105 105 printf("Position of the second Part referenced by this joint (part #%d) is now changed:\n\n%s\n", 106 j->part2->refno, (const char*)j->getModel().getF0Geno().getGene());106 j->part2->refno, j->getModel().getF0Geno().getGene().c_str()); 107 107 printf("If no delta fields are defined, they will be computed automatically.\n" 108 108 "You can always delete existing delta values by using Joint::resetDelta().\n" … … 112 112 j->resetDelta(); 113 113 j->getModel().close(); 114 printf("As you can see, Joint's delta fields have altered:\n\n%s\n", (const char*)j->getModel().getF0Geno().getGene());114 printf("As you can see, Joint's delta fields have altered:\n\n%s\n", j->getModel().getF0Geno().getGene().c_str()); 115 115 } 116 116 … … 123 123 j->getModel().close(); 124 124 printf("f0 is now:\n\n%s\n...so this is %s joint.\n", 125 (const char*)j->getModel().getF0Geno().getGene(), option?"a delta":"an absolute");125 j->getModel().getF0Geno().getGene().c_str(), option?"a delta":"an absolute"); 126 126 127 127 } … … 155 155 CHANGE_ONE_PROPERTY(j->extraProperties()); 156 156 j->getModel().close(); 157 printf("And after that we have this genotype:\n\n%s\n", (const char*)j->getModel().getF0Geno().getGene());157 printf("And after that we have this genotype:\n\n%s\n", j->getModel().getF0Geno().getGene().c_str()); 158 158 } 159 159 … … 178 178 printf("\nThe most unusual thing is 'details' field (d).\n" 179 179 "It is something like separate object with its own set of properties.\n" 180 "Currently the value of 'd' is '%s'.\n", (const char*)n->getDetails());180 "Currently the value of 'd' is '%s'.\n",n->getDetails().c_str()); 181 181 182 182 { 183 183 NeuroClass* cl=n->getClass(); 184 184 if (!cl) 185 printf("It should contain the class name but the meaning of '%s' is unknown\n", (const char*)n->getDetails());185 printf("It should contain the class name but the meaning of '%s' is unknown\n",n->getDetails().c_str()); 186 186 else 187 187 { 188 188 189 189 printf("'%s' is the class name (Neuro::getClassName() == '%s') and means '%s'.\n", 190 (const char*)cl->getName(),(const char*)cl->getName(),(const char*)cl->getLongName());190 cl->getName().c_str(),cl->getName().c_str(),cl->getLongName().c_str()); 191 191 printf("Neuro::getClass() gives you information about basic characteristic\n" 192 192 "of the class, that can be analyzed automatically.\n"); … … 208 208 p.update(); 209 209 n->getModel().close(); 210 printf("After that, 'details' contains the new object: '%s'.\n", (const char*)n->getDetails());210 printf("After that, 'details' contains the new object: '%s'.\n",n->getDetails().c_str()); 211 211 } 212 212 else … … 224 224 NeuroClass* cl=n->getClass(i); 225 225 Param p=cl->getProperties(); 226 printf("%2d.%6s %-20s %2d\n",i, (const char*)cl->getName(),(const char*)cl->getLongName(),p.getPropCount());226 printf("%2d.%6s %-20s %2d\n",i,cl->getName().c_str(),cl->getLongName().c_str(),p.getPropCount()); 227 227 } 228 228 int cl=rand() % n->getClassCount(); 229 printf("\nLet's change the Neuro's class to '%s'...\n", (const char*)n->getClassName(cl));229 printf("\nLet's change the Neuro's class to '%s'...\n",n->getClassName(cl).c_str()); 230 230 n->getModel().open(); 231 231 n->setClass(n->getClass(cl)); … … 242 242 if (n->getInputCount()>0) 243 243 { 244 printf("Info for input #0 = \"%s\"\n", (const char*)n->getInputInfo(0));245 printf("Info for input #0, field \"%s\" = \"%s\"\n", "abc", (const char*)n->getInputInfo(0,"abc"));244 printf("Info for input #0 = \"%s\"\n",n->getInputInfo(0).c_str()); 245 printf("Info for input #0, field \"%s\" = \"%s\"\n", "abc", n->getInputInfo(0,"abc").c_str()); 246 246 n->setInputInfo(0,"test",44); 247 247 n->setInputInfo(0,"abc","yeah"); … … 250 250 n->getModel().close(); 251 251 printf("The final object description will be then: '%s'\nAnd the full f0 genotype:\n\n%s\n", 252 (const char*)n->getDetails(), (const char*)n->getModel().getF0Geno().getGene());252 n->getDetails().c_str(), n->getModel().getF0Geno().getGene().c_str()); 253 253 254 254 … … 257 257 void findingConverters() 258 258 { 259 GenoConverter *gc=Geno::getConverters() .findConverters(0,'1');259 GenoConverter *gc=Geno::getConverters()->findConverters(0,'1'); 260 260 if (gc) printf("found converter accepting f1: \"%s\"\n",gc->name); 261 261 SListTempl<GenoConverter*> found; 262 Geno::getConverters() .findConverters(&found,-1,'0');262 Geno::getConverters()->findConverters(&found,-1,'0'); 263 263 printf("found %d converter(s) producing f0\n",found.size()); 264 264 } … … 274 274 275 275 SString gen(argc>1?argv[1]:"X[|G:1.23]"); 276 if (!strcmp(gen ,"-"))276 if (!strcmp(gen.c_str(),"-")) 277 277 { 278 278 gen=0; … … 281 281 } 282 282 Geno g(gen); 283 printf("\nSource genotype: '%s'\n", (const char*)g.getGene());283 printf("\nSource genotype: '%s'\n",g.getGene().c_str()); 284 284 printf(" ( format %c %s)\n", 285 g.getFormat(), (const char*)g.getComment());285 g.getFormat(), g.getComment().c_str()); 286 286 287 287 Model m(g);//.getConverted('0')); … … 292 292 return 2; 293 293 } 294 printf("Converted to f0:\n%s\n", (const char*)m.getF0Geno().getGene());294 printf("Converted to f0:\n%s\n",m.getF0Geno().getGene().c_str()); 295 295 296 296 printf("Model contains: %d part(s)\n" … … 340 340 NeuroItem *ni=n->getNeuroItem(j); 341 341 printf(" item #%d - '%s', conn=%d, weight=%g\n", 342 j, (const char*)ni->getDetails(),ni->conn_refno,ni->weight);342 j,ni->getDetails().c_str(),ni->conn_refno,ni->weight); 343 343 } 344 344 }
Note: See TracChangeset
for help on using the changeset viewer.