Ignore:
Timestamp:
02/26/14 20:21:22 (10 years ago)
Author:
sz
Message:

Genetics reorganization (affects ALL applications!):

  • Converters/Validators? are now configured/initialized in a more verbose but also less confusing way
  • At the same time, the PreconfiguredGenetics? object will help you avoid the increased complexity by creating the ready-to-use environment that is sufficient in 99% of cases (see the demos)
  • Format F genetics updated (work in progress)
File:
1 edited

Legend:

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

    r141 r145  
    33// Refer to http://www.framsticks.com/ for further information.
    44
    5 #include <frams/genetics/genman.h>
    65#include <frams/errmgr/stdouterr.h>
    7 #include <frams/genetics/defgenoconv.h>
    8 
    9 StdoutErrorHandler err;
    10 DefaultGenoConvManager gcm; //without this object the application would only handle "format 0" genotypes
     6#include <frams/genetics/preconfigured.h>
    117
    128void printGen(Geno &g)
     
    2521int main(int argc, char *argv[])
    2622{
    27         GenMan gm;
    28         Geno::validators.insert(0,&gm); //GenMan is available in this application so let's use the extended validity checking!
    29         // Note: insert() makes it the first validator in the list, this is important for formats that rely on genetic operators to perform reasonable validation,
    30         // otherwise the default validator (genotype converter) would "win" and most converters are less strict in detecting invalid genotypes.
    31         gm.p_report(NULL, NULL);
     23        StdoutErrorHandler err;//the default ErrorHandler constructor automatically registers this object to receive framsg messages (and in this case, redirect them to standard output)
     24        PreconfiguredGenetics genetics;
     25
     26        rndGetInstance().randomize();
     27        genetics.genman.p_report(NULL, NULL);
    3228
    3329        const char* src = (argc > 1) ? argv[1] : "/*9*/UUU";
    3430        Geno gsrc(src, -1, "First");
    3531        printGenAndTitle(gsrc, "source genotype (gsrc)");
     32        char format = gsrc.getFormat();
    3633
    37         Geno gmut = gm.Mutate(gsrc);
     34        Geno gmut = genetics.genman.Mutate(gsrc);
    3835        printGenAndTitle(gmut, "mutated (gmut)");
    3936
    40         Geno gxover = gm.CrossOver(gsrc, gmut);
     37        Geno gxover = genetics.genman.CrossOver(gsrc, gmut);
    4138        printGenAndTitle(gxover, "crossed over (gsrc and gmut)");
    4239
    43         Geno gsimplest = gm.GetSimplest('9');
     40        Geno gsimplest = genetics.genman.GetSimplest(format);
    4441        printGenAndTitle(gsimplest, "simplest");
    4542
    46         Geno ginvalid("IT'S REALLY WRONG", '9');
     43        Geno ginvalid("IT'S REALLY WRONG", format);
    4744        printGenAndTitle(ginvalid, "invalid");
    4845
    49         Geno gvalidated = gm.Validate(ginvalid);
     46        Geno gvalidated = genetics.genman.Validate(ginvalid);
    5047        printGenAndTitle(gvalidated, "validated");
    5148
    52         printf("\nHTMLized: %s\n", (const char*)gm.HTMLize((const char*)gvalidated.getGene()));
     49        printf("\nHTMLized: %s\n", (const char*)genetics.genman.HTMLize((const char*)gvalidated.getGene()));
    5350
    5451        return 0;
Note: See TracChangeset for help on using the changeset viewer.