Changeset 1018 for cpp


Ignore:
Timestamp:
07/20/20 16:54:30 (4 years ago)
Author:
Maciej Komosinski
Message:

Make genomanipulation.cpp results consistent across platforms by using our random number generator instead of stdlib's

File:
1 edited

Legend:

Unmodified
Added
Removed
  • cpp/frams/_demos/genomanipulation.cpp

    r1009 r1018  
    4141{
    4242        if (pi.getPropCount() <= 0) return;
    43         int i = rand() % pi.getPropCount();
     43        int i = rndUint(pi.getPropCount());
    4444        double maxprop = 1, minprop = 0, def;
    4545        pi.getMinMaxDouble(i, minprop, maxprop, def);
     
    251251                printf("%2d.%6s  %-20s  %2d\n", i, cl->getName().c_str(), cl->getLongName().c_str(), p.getPropCount());
    252252        }
    253         int cl = rand() % n->getClassCount();
     253        int cl = rndUint(n->getClassCount());
    254254        printf("\nLet's change the Neuro's class to '%s'...\n", n->getClassName(cl).c_str());
    255255        n->getModel().open();
     
    294294        PreconfiguredGenetics genetics;
    295295
    296         //srand(time(0)); //uncomment to see the demonstration of different behaviors and results on each run
     296        //rndRandomizeSeed(); //uncomment to see the demonstration of different behaviors and results on each run
    297297        printNiceBanner("Welcome to Genotype Manipulation Demo!");
    298298
     
    328328        if (m.getPartCount() > 0)
    329329        {
    330                 int p = rand() % m.getPartCount();
     330                int p = rndUint(m.getPartCount());
    331331                printNiceBanner("P A R T    O B J E C T");
    332332                printf("            (part # %d)\n", p);
     
    336336        if (m.getJointCount() > 0)
    337337        {
    338                 int j = rand() % m.getJointCount();
     338                int j = rndUint(m.getJointCount());
    339339                printNiceBanner("J O I N T    O B J E C T");
    340340                printf("            (joint # %d)\n", j);
     
    344344        if (m.getNeuroCount() > 0)
    345345        {
    346                 int n = rand() % m.getNeuroCount();
     346                int n = rndUint(m.getNeuroCount());
    347347                printNiceBanner("N E U R O    O B J E C T");
    348348                printf("            (neuro # %d)\n", n);
     
    376376                "  1. You can redirect output: genomanipulation >filename.txt\n"
    377377                "  2. Each run can yield different results and new behaviors, but you\n"
    378                 "     need to uncomment srand(time(0)) in genomanipulation.cpp.\n"
     378                "     need to uncomment rndRandomizeSeed() in genomanipulation.cpp.\n"
    379379                "  3. This application will use custom genotype passed as\n"
    380380                "     a commandline parameter: genomanipulation \"/*9*/FULU\"\n"
Note: See TracChangeset for help on using the changeset viewer.