Changeset 972 for cpp/frams


Ignore:
Timestamp:
07/03/20 00:32:23 (4 years ago)
Author:
Maciej Komosinski
Message:
  • separate "0" and "0s" formats (for SHAPE_BALL_AND_STICK and SHAPE_SOLIDS, respectively)
  • converting to format list (Geno::F0_FORMAT_LIST = "0,0s")
  • (optional) declaring Model as SHAPE_BALL_AND_STICK or SHAPE_SOLIDS (or SHAPE_UNKNOWN)
Location:
cpp/frams
Files:
20 edited

Legend:

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

    r955 r972  
    11// This file is a part of Framsticks SDK.  http://www.framsticks.com/
    2 // Copyright (C) 1999-2016  Maciej Komosinski and Szymon Ulatowski.
     2// Copyright (C) 1999-2020  Maciej Komosinski and Szymon Ulatowski.
    33// See LICENSE.txt for details.
    44
     
    1212#include <common/loggers/loggertostdout.h>
    1313
    14 void save_as_f0(SString &gen,Model &m,bool omit_default_values)
     14void save_as_f0(SString &gen, Model &m, bool omit_default_values)
    1515{
    16 // copied from Model::makeGeno() (with small changes)
     16        // copied from Model::makeGeno() (with small changes)
    1717
    18 static Param modelparam(f0_model_paramtab);
    19 static Param partparam(f0_part_paramtab);
    20 static Param jointparam(f0_joint_paramtab);
    21 static Param neuroparam(f0_neuro_paramtab);
    22 static Param connparam(f0_neuroconn_paramtab);
     18        static Param modelparam(f0_model_paramtab);
     19        static Param partparam(f0_part_paramtab);
     20        static Param jointparam(f0_joint_paramtab);
     21        static Param neuroparam(f0_neuro_paramtab);
     22        static Param connparam(f0_neuroconn_paramtab);
    2323
    24 static Part defaultpart;
    25 static Joint defaultjoint;
    26 static Neuro defaultneuro;
    27 static Model defaultmodel;
    28 static NeuroConn defaultconn;
     24        static Part defaultpart;
     25        static Joint defaultjoint;
     26        static Neuro defaultneuro;
     27        static Model defaultmodel;
     28        static NeuroConn defaultconn;
    2929
    30 modelparam.select(&m);
    31 gen+="m:";
    32 modelparam.saveSingleLine(gen,omit_default_values ? &defaultmodel : NULL);
     30        modelparam.select(&m);
     31        gen += "m:";
     32        modelparam.saveSingleLine(gen, omit_default_values ? &defaultmodel : NULL);
    3333
    34 Part *p;
    35 Joint *j;
    36 Neuro *n;
     34        Part *p;
     35        Joint *j;
     36        Neuro *n;
    3737
    38 for (int i=0;p=(Part*)m.getPart(i);i++)
     38        for (int i = 0; p = (Part*)m.getPart(i); i++)
    3939        {
    40         partparam.select(p);
    41         gen+="p:";
    42         partparam.saveSingleLine(gen,omit_default_values ? &defaultpart : NULL);
     40                partparam.select(p);
     41                gen += "p:";
     42                partparam.saveSingleLine(gen, omit_default_values ? &defaultpart : NULL);
    4343        }
    44 for (int i=0;j=(Joint*)m.getJoint(i);i++)
     44        for (int i = 0; j = (Joint*)m.getJoint(i); i++)
    4545        {
    46         jointparam.select(j);
    47         jointparam.setParamTab(j->usedelta?f0_joint_paramtab:f0_nodeltajoint_paramtab);
    48         gen+="j:";
    49         jointparam.saveSingleLine(gen,omit_default_values ? &defaultjoint : NULL);
     46                jointparam.select(j);
     47                jointparam.setParamTab(j->usedelta ? f0_joint_paramtab : f0_nodeltajoint_paramtab);
     48                gen += "j:";
     49                jointparam.saveSingleLine(gen, omit_default_values ? &defaultjoint : NULL);
    5050        }
    51 for (int i=0;n=(Neuro*)m.getNeuro(i);i++)
     51        for (int i = 0; n = (Neuro*)m.getNeuro(i); i++)
    5252        {
    53         neuroparam.select(n);
    54         gen+="n:";
    55         neuroparam.saveSingleLine(gen,omit_default_values ? &defaultneuro : NULL);
     53                neuroparam.select(n);
     54                gen += "n:";
     55                neuroparam.saveSingleLine(gen, omit_default_values ? &defaultneuro : NULL);
    5656        }
    57 for (int a=0;n=(Neuro*)m.getNeuro(a);a++)
     57        for (int a = 0; n = (Neuro*)m.getNeuro(a); a++)
    5858        { // inputs
    59         for (int b=0;b<n->getInputCount();b++)
     59                for (int b = 0; b < n->getInputCount(); b++)
    6060                {
    61                 double w;
    62                 NeuroConn nc;
    63                 Neuro* n2=n->getInput(b,w);
    64                 nc.n1_refno=n->refno; nc.n2_refno=n2->refno;
    65                 nc.weight=w;
    66                 nc.info=n->getInputInfo(b);
    67                 connparam.select(&nc);
    68                 gen+="c:";
    69                 connparam.saveSingleLine(gen,omit_default_values ? &defaultconn : NULL);
     61                        double w;
     62                        NeuroConn nc;
     63                        Neuro* n2 = n->getInput(b, w);
     64                        nc.n1_refno = n->refno; nc.n2_refno = n2->refno;
     65                        nc.weight = w;
     66                        nc.info = n->getInputInfo(b);
     67                        connparam.select(&nc);
     68                        gen += "c:";
     69                        connparam.saveSingleLine(gen, omit_default_values ? &defaultconn : NULL);
    7070                }
    7171        }
    7272}
    7373
    74 int main(int argc,char*argv[])
     74int main(int argc, char*argv[])
    7575{
    76 LoggerToStdout messages_to_stdout(LoggerBase::Enable);
     76        LoggerToStdout messages_to_stdout(LoggerBase::Enable);
    7777
    78 //without converters the application would only handle "format 0" genotypes
    79 DefaultGenoConvManager gcm;
    80 gcm.addDefaultConverters();
    81 Geno::useConverters(&gcm);
     78        //without converters the application would only handle "format 0" genotypes
     79        DefaultGenoConvManager gcm;
     80        gcm.addDefaultConverters();
     81        Geno::useConverters(&gcm);
    8282
    83 Geno::Validators validators;
    84 Geno::useValidators(&validators);
    85 ModelGenoValidator model_validator;
    86 validators+=&model_validator; //This simple validator handles all cases where a converter for a particular format is available but there is no genetic operator. Converters may be less strict in detecting invalid genotypes but it is better than nothing
     83        Geno::Validators validators;
     84        Geno::useValidators(&validators);
     85        ModelGenoValidator model_validator;
     86        validators += &model_validator; //This simple validator handles all cases where a converter for a particular format is available but there is no genetic operator. Converters may be less strict in detecting invalid genotypes but it is better than nothing
    8787
    88 SString gen(argc>1?argv[1]:"X[|G:1.23]");
    89 if (!strcmp(gen.c_str(),"-"))
     88        SString gen(argc > 1 ? argv[1] : "X[|G:1.23]");
     89        if (!strcmp(gen.c_str(), "-"))
    9090        {
    91         gen=0;
    92         StdioFILEDontClose in(stdin);
    93         loadSString(&in,gen);
     91                gen = 0;
     92                StdioFILEDontClose in(stdin);
     93                loadSString(&in, gen);
    9494        }
    95 Geno g(gen);
    96 printf("\nSource genotype: '%s'\n",g.getGenes().c_str());
    97 printf("                  ( format %s %s)\n",
    98        g.getFormat().c_str(), g.getComment().c_str());
     95        Geno g(gen);
     96        printf("\nSource genotype: '%s'\n", g.getGenes().c_str());
     97        printf("                  ( format %s %s)\n",
     98                g.getFormat().c_str(), g.getComment().c_str());
    9999
    100 Model m(g);//.getConverted('0'));
     100        Model m(g, Model::SHAPE_UNKNOWN);//.getConverted('0'));
    101101
    102 if (!m.isValid())
     102        if (!m.isValid())
    103103        {
    104         printf("Cannot build Model from this genotype!\n");
    105         return 2;       
     104                printf("Cannot build Model from this genotype!\n");
     105                return 2;
    106106        }
    107107
    108 printf("\nthis example shows how to save a f0 genotype using low-level ParamInterface::saveSingleLine() calls\n");
     108        printf("\nthis example shows how to save a f0 genotype using low-level ParamInterface::saveSingleLine() calls\n");
    109109
    110 SString f0_skipping_defaults;
    111 SString f0_no_skipping_defaults;
     110        SString f0_skipping_defaults;
     111        SString f0_no_skipping_defaults;
    112112
    113 save_as_f0(f0_skipping_defaults,m,true);
    114 save_as_f0(f0_no_skipping_defaults,m,false);
     113        save_as_f0(f0_skipping_defaults, m, true);
     114        save_as_f0(f0_no_skipping_defaults, m, false);
    115115
    116 printf("\n==== with defdata (skips default values) ======\n%s\n",f0_skipping_defaults.c_str());
    117 printf("\n==== without defdata (saves all fields) ======\n%s\n",f0_no_skipping_defaults.c_str());
     116        printf("\n==== with defdata (skips default values) ======\n%s\n", f0_skipping_defaults.c_str());
     117        printf("\n==== without defdata (saves all fields) ======\n%s\n", f0_no_skipping_defaults.c_str());
    118118
    119 return 0;
     119        return 0;
    120120}
    121121
     
    123123
    124124Source genotype: 'X[|G:1.23]'
    125                   ( format 1 )
     125                                  ( format 1 )
    126126
    127127this example shows how to save a f0 genotype using low-level ParamInterface::saveSingleLine() calls
  • cpp/frams/_demos/full_props.cpp

    r534 r972  
    11// This file is a part of Framsticks SDK.  http://www.framsticks.com/
    2 // Copyright (C) 1999-2016  Maciej Komosinski and Szymon Ulatowski.
     2// Copyright (C) 1999-2020  Maciej Komosinski and Szymon Ulatowski.
    33// See LICENSE.txt for details.
    44
     
    4747*/
    4848
    49 int main(int argc,char*argv[])
     49int main(int argc, char*argv[])
    5050{
    51 StdioFILE::setStdio();//setup VirtFILE::Vstdin/out/err
    52 LoggerToStdout messages_to_stderr(LoggerBase::Enable | LoggerBase::DontBlock,VirtFILE::Vstderr); //errors -> stderr, don't interfere with stdout
     51        StdioFILE::setStdio();//setup VirtFILE::Vstdin/out/err
     52        LoggerToStdout messages_to_stderr(LoggerBase::Enable | LoggerBase::DontBlock, VirtFILE::Vstderr); //errors -> stderr, don't interfere with stdout
    5353
    54 PreconfiguredGenetics genetics;
     54        PreconfiguredGenetics genetics;
    5555
    56 bool reverse=false;
    57 char* gen_arg=0;
    58 for(int i=1;i<argc;i++)
     56        bool reverse = false;
     57        char* gen_arg = 0;
     58        for (int i = 1; i < argc; i++)
    5959        {
    60         char* ar=argv[i];
    61         if (ar[0]=='-')
    62                 switch(ar[1])
     60                char* ar = argv[i];
     61                if (ar[0] == '-')
     62                        switch (ar[1])
    6363                        {
    64                         case 'r': reverse=true; break;
     64                        case 'r': reverse = true; break;
    6565                        case 'h': puts("usage: full_props [-r[everse]] [genotype_or_stdin]\n"); break;
    6666                        }
     67                else
     68                        if (!gen_arg)
     69                                gen_arg = ar;
     70        }
     71        SString gen;
     72        if (gen_arg)
     73                gen = gen_arg;
    6774        else
    68                 if (!gen_arg)
    69                         gen_arg=ar;
    70         }
    71 SString gen;
    72 if (gen_arg)
    73         gen=gen_arg;
    74 else
    75         loadSString(VirtFILE::Vstdin,gen);
    76 Geno g(gen);
    77 Model m(g);
     75                loadSString(VirtFILE::Vstdin, gen);
     76        Geno g(gen);
     77        Model m(g, Model::SHAPE_UNKNOWN);
    7878
    79 if (!m.isValid())
     79        if (!m.isValid())
    8080        {
    81         logPrintf("","full_props",LOG_ERROR,"Cannot build Model from the supplied genotype\n");
    82         return 2;       
     81                logPrintf("", "full_props", LOG_ERROR, "Cannot build Model from the supplied genotype\n");
     82                return 2;
    8383        }
    8484
    85 m.open();
    86 for(int i=0;i<m.getNeuroCount();i++)
     85        m.open();
     86        for (int i = 0; i < m.getNeuroCount(); i++)
    8787        {
    88         Neuro *n=m.getNeuro(i);
    89         SyntParam p=n->classProperties(reverse);
    90         p.update();// ...so everyone reading the source can recognize that p was created to update the neuro d field
    91         // but actually, calling update() here is not necessary, because ~SyntParam() would do it anyway
     88                Neuro *n = m.getNeuro(i);
     89                SyntParam p = n->classProperties(reverse);
     90                p.update();// ...so everyone reading the source can recognize that p was created to update the neuro d field
     91                // but actually, calling update() here is not necessary, because ~SyntParam() would do it anyway
    9292        }
    93 m.close();
     93        m.close();
    9494
    95 // normal f0 (omitting default values) would be retrieved using m.getF0Geno()
    96 // the following form allows for more control:
    97 Geno f0_g;
    98 m.makeGeno(f0_g,NULL,reverse);//third arg is "handle_defaults" == whether f0 should omit default property values
    99 puts(f0_g.getGenesAndFormat().c_str());
     95        // normal f0 (omitting default values) would be retrieved using m.getF0Geno()
     96        // the following form allows for more control:
     97        Geno f0_g;
     98        m.makeGeno(f0_g, NULL, reverse);//third arg is "handle_defaults" == whether f0 should omit default property values
     99        puts(f0_g.getGenesAndFormat().c_str());
    100100
    101 return 0;
     101        return 0;
    102102}
    103103
  • cpp/frams/_demos/genoconv_test.cpp

    r955 r972  
    11// This file is a part of Framsticks SDK.  http://www.framsticks.com/
    2 // Copyright (C) 1999-2018  Maciej Komosinski and Szymon Ulatowski.
     2// Copyright (C) 1999-2020  Maciej Komosinski and Szymon Ulatowski.
    33// See LICENSE.txt for details.
    44
     
    1616 */
    1717
    18 /// Sample Geno converter not using Model class.
    19 /// (This converter generates the same output for each input).
    20 /// Such a converter is responsible for doing valid f0 (or other format) output and storing temporary data.
     18 /// Sample Geno converter not using Model class.
     19 /// (This converter generates the same output for each input).
     20 /// Such a converter is responsible for doing valid f0 (or other format) output and storing temporary data.
    2121class GenoConv_Test : public GenoConverter
    2222{
     
    8484        for (t = src; *t; t++)
    8585        {
    86                 if (insideneuron&&*t == ']') insideneuron = 0;
     86                if (insideneuron && *t == ']') insideneuron = 0;
    8787                if (*t == '[') insideneuron = 1;
    8888                if ((!insideneuron) && isdigit(*t) && t[1])
     
    9393                                dst += *t;
    9494                        if (map) // fill in the map only if requested
    95                                 map->add(t - src, t - src, dst.len() - n, dst.len() - 1);
     95                                map->add(t - src, t - src, dst.length() - n, dst.length() - 1);
    9696                        // meaning: source character (t-src) becomes (dst.len()-n ... dst.len()-1)
    9797                }
     
    100100                        dst += *t;
    101101                        if (map)
    102                                 map->add(t - src, t - src, dst.len() - 1, dst.len() - 1);
     102                                map->add(t - src, t - src, dst.length() - 1, dst.length() - 1);
    103103                        // meaning: map single to single character: (t-src) into (dst.len()-1)
    104104                }
     
    113113{
    114114        printf("Genotype:\n%s\nFormat: %s\nValid: %s\nComment: %s\n",
    115                g.getGenes().c_str(), g.getFormat().c_str(), g.isValid() ? "yes" : "no", g.getComment().c_str());
     115                g.getGenes().c_str(), g.getFormat().c_str(), g.isValid() ? "yes" : "no", g.getComment().c_str());
    116116}
    117117
     
    167167        if (using_checkpoints)
    168168        { // using Model with checkpoints
    169                 Model m1(g2, false, true);//true=using_checkpoints
     169                Model m1(g2, Model::SHAPE_UNKNOWN, false, true);//true=using_checkpoints
    170170                printf("\nModel built from the converted f%s genotype has %d checkpoints\n", g2.getFormat().c_str(), m1.getCheckpointCount());
    171                 Model m2(g1, false, true);//true=using_checkpoints
     171                Model m2(g1, Model::SHAPE_UNKNOWN, false, true);//true=using_checkpoints
    172172                printf("Model built from the source f%s genotype has %d checkpoints\n", g1.getFormat().c_str(), m2.getCheckpointCount());
    173173                // accessing individual checkpoint models (if available)
     
    195195                }
    196196
    197                 Model mod1(g1, 1);
     197                Model mod1(g1, Model::SHAPE_UNKNOWN, 1);
    198198                printf("\nModel map for f%s genotype:\n", g1.getFormat().c_str());
    199199                ModelDisplayMap dm1(mod1);
     
    202202                mod1combined.addCombined(mod1.getMap(), dm1.getMap());
    203203                mod1combined.print();
    204                 Model mod2(g2, 1);
     204                Model mod2(g2, Model::SHAPE_UNKNOWN, 1);
    205205                printf("\nModel map for f%s genotype:\n", g2.getFormat().c_str());
    206206                ModelDisplayMap dm2(mod2);
  • cpp/frams/_demos/genomanipulation.cpp

    r955 r972  
    11// This file is a part of Framsticks SDK.  http://www.framsticks.com/
    2 // Copyright (C) 1999-2019  Maciej Komosinski and Szymon Ulatowski.
     2// Copyright (C) 1999-2020  Maciej Komosinski and Szymon Ulatowski.
    33// See LICENSE.txt for details.
    44
     
    210210                        else
    211211                                printf("(This class does not have its own properties\n"
    212                                 " - Neuro::classProperties().getPropCount()==0)\n");
     212                                        " - Neuro::classProperties().getPropCount()==0)\n");
    213213                }
    214214        }
     
    230230        {
    231231                SyntParam p = n->classProperties();
    232                 if (p.getPropCount()>0)
     232                if (p.getPropCount() > 0)
    233233                {
    234234                        printProperties(p);
     
    284284                g.getFormat().c_str(), g.getComment().c_str());
    285285
    286         Model m(g);//.getConverted('0'));
     286        Model m(g, Model::SHAPE_UNKNOWN);//.getConverted('0'));
    287287
    288288        if (!m.isValid())
  • cpp/frams/_demos/geometry/geometrytestutils.cpp

    r737 r972  
    11// This file is a part of Framsticks SDK.  http://www.framsticks.com/
    2 // Copyright (C) 1999-2017  Maciej Komosinski and Szymon Ulatowski.
     2// Copyright (C) 1999-2020  Maciej Komosinski and Szymon Ulatowski.
    33// See LICENSE.txt for details.
    44
     
    2424        {
    2525                count++;
    26                 totalSize += genotype->genotype.len();
    27 
    28                 fprintf(stderr, "%d. (%6d chars) %s\n", count, genotype->genotype.len(),
     26                totalSize += genotype->genotype.length();
     27
     28                fprintf(stderr, "%d. (%6d chars) %s\n", count, genotype->genotype.length(),
    2929                        genotype->name.c_str());
    3030        }
     
    6363                if ((genoIndex == count) || (strcmp(genotype->name.c_str(), genoName) == 0))
    6464                {
    65                         Model model(genotype->genotype);
     65                        Model model(genotype->genotype, Model::SHAPE_UNKNOWN);
    6666
    6767                        if (!model.isValid())
  • cpp/frams/_demos/multiline_f0_test.cpp

    r955 r972  
    11// This file is a part of Framsticks SDK.  http://www.framsticks.com/
    2 // Copyright (C) 1999-2015  Maciej Komosinski and Szymon Ulatowski.
     2// Copyright (C) 1999-2020  Maciej Komosinski and Szymon Ulatowski.
    33// See LICENSE.txt for details.
    44
     
    1313#include <common/virtfile/stringfile.h>
    1414
    15 int main(int argc,char*argv[])
     15int main(int argc, char*argv[])
    1616{
    17 LoggerToStdout messages_to_stdout(LoggerBase::Enable);
    18 PreconfiguredGenetics genetics;
     17        LoggerToStdout messages_to_stdout(LoggerBase::Enable);
     18        PreconfiguredGenetics genetics;
    1919
    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(), "-"))
    2222        {
    23         gen=0;
    24         StdioFILEDontClose in(stdin);
    25         loadSString(&in,gen);
     23                gen = 0;
     24                StdioFILEDontClose in(stdin);
     25                loadSString(&in, gen);
    2626        }
    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());
     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());
    3131
    32 Model m(g);//.getConverted('0'));
     32        Model m(g, Model::SHAPE_UNKNOWN);//.getConverted('0'));
    3333
    34 if (!m.isValid())
     34        if (!m.isValid())
    3535        {
    36         printf("Cannot build Model from this genotype!\n");
    37         return 2;       
     36                printf("Cannot build Model from this genotype!\n");
     37                return 2;
    3838        }
    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());
    4040
    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)");
    4242
    43 StringFILE2 f;
     43        StringFILE2 f;
    4444
    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);
    5050
    51 modelparam.select(&m);
    52 modelparam.saveMultiLine(&f,"m");
     51        modelparam.select(&m);
     52        modelparam.saveMultiLine(&f, "m");
    5353
    54 Part *p;
    55 Joint *j;
    56 Neuro *n;
     54        Part *p;
     55        Joint *j;
     56        Neuro *n;
    5757
    58 for (int i=0;p=(Part*)m.getPart(i);i++)
     58        for (int i = 0; p = (Part*)m.getPart(i); i++)
    5959        {
    60         partparam.select(p);
    61         partparam.saveMultiLine(&f,"p");
     60                partparam.select(p);
     61                partparam.saveMultiLine(&f, "p");
    6262        }
    63 for (int i=0;j=(Joint*)m.getJoint(i);i++)
     63        for (int i = 0; j = (Joint*)m.getJoint(i); i++)
    6464        {
    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");
    6868        }
    69 for (int i=0;n=(Neuro*)m.getNeuro(i);i++)
     69        for (int i = 0; n = (Neuro*)m.getNeuro(i); i++)
    7070        {
    71         neuroparam.select(n);
    72         neuroparam.saveMultiLine(&f,"n");
     71                neuroparam.select(n);
     72                neuroparam.saveMultiLine(&f, "n");
    7373        }
    74 for (int a=0;n=(Neuro*)m.getNeuro(a);a++)
     74        for (int a = 0; n = (Neuro*)m.getNeuro(a); a++)
    7575        { // inputs
    76         for (int b=0;b<n->getInputCount();b++)
     76                for (int b = 0; b < n->getInputCount(); b++)
    7777                {
    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");
    8686                }
    8787        }
    8888
    89 printf("\n============================\n%s\n",f.getString().c_str());
     89        printf("\n============================\n%s\n", f.getString().c_str());
    9090
    91 return 0;
     91        return 0;
    9292}
    9393
     
    9595
    9696Source genotype: 'X[|G:1.23]'
    97                   ( format 1 )
     97                                  ( format 1 )
    9898Converted to f0:
    9999p:
  • cpp/frams/_demos/neuro_layout_test.cpp

    r408 r972  
    11// This file is a part of Framsticks SDK.  http://www.framsticks.com/
    2 // Copyright (C) 1999-2015  Maciej Komosinski and Szymon Ulatowski.
     2// Copyright (C) 1999-2020  Maciej Komosinski and Szymon Ulatowski.
    33// See LICENSE.txt for details.
    44
     
    2121
    2222// stl is fun? ;-) ForwardIterator implementation for element coordinates (required by min_element/max_element)
    23 template <int MEMBER> struct NNIter: public std::iterator<std::forward_iterator_tag,int> //MEMBER: 0..3=x/y/w/h
     23template <int MEMBER> struct NNIter : public std::iterator<std::forward_iterator_tag, int> //MEMBER: 0..3=x/y/w/h
    2424{
    25 NNLayoutState *nn; int index;
    26 NNIter() {}
    27 NNIter(NNLayoutState *_nn, int _index):nn(_nn),index(_index) {}
    28 int operator*() {return nn->GetXYWH(index)[MEMBER];}
    29 NNIter& operator++() {index++; return *this;}
    30 bool operator!=(const NNIter& it) {return index!=it.index;}
    31 bool operator==(const NNIter& it) {return index==it.index;}
     25        NNLayoutState *nn; int index;
     26        NNIter() {}
     27        NNIter(NNLayoutState *_nn, int _index) :nn(_nn), index(_index) {}
     28        int operator*() { return nn->GetXYWH(index)[MEMBER]; }
     29        NNIter& operator++() { index++; return *this; }
     30        bool operator!=(const NNIter& it) { return index != it.index; }
     31        bool operator==(const NNIter& it) { return index == it.index; }
    3232
    33 static NNIter begin(NNLayoutState *_nn) {return NNIter(_nn,0);}
    34 static NNIter end(NNLayoutState *_nn) {return NNIter(_nn,_nn->GetElements());}
     33        static NNIter begin(NNLayoutState *_nn) { return NNIter(_nn, 0); }
     34        static NNIter end(NNLayoutState *_nn) { return NNIter(_nn, _nn->GetElements()); }
    3535};
    3636
    3737class Screen
    3838{
    39 int min_x,max_x,min_y,max_y,scale_x,scale_y;
    40 int rows,columns;
    41 char* screen;
     39        int min_x, max_x, min_y, max_y, scale_x, scale_y;
     40        int rows, columns;
     41        char* screen;
    4242
    4343public:
    4444
    45 Screen(int _min_x,int _max_x,int _min_y,int _max_y,int _scale_x,int _scale_y)
    46         :min_x(_min_x),max_x(_max_x),min_y(_min_y),max_y(_max_y),scale_x(_scale_x),scale_y(_scale_y)
     45        Screen(int _min_x, int _max_x, int _min_y, int _max_y, int _scale_x, int _scale_y)
     46                :min_x(_min_x), max_x(_max_x), min_y(_min_y), max_y(_max_y), scale_x(_scale_x), scale_y(_scale_y)
     47        {
     48                columns = (max_x - min_x + scale_x - 1) / scale_x;
     49                rows = (max_y - min_y + scale_y - 1) / scale_y;
     50                screen = new char[rows * columns];
     51                memset(screen, ' ', rows * columns);
     52        }
     53
     54        ~Screen()
     55        {
     56                delete[] screen;
     57        }
     58
     59        void put(int x, int y, const char *str)
     60        {
     61                x = (x - min_x) / scale_x;
     62                y = (y - min_y) / scale_y;
     63                if (x < 0) return;
     64                if (y < 0) return;
     65                if (y >= rows) return;
     66                for (; *str; str++, x++)
    4767                {
    48                 columns=(max_x-min_x+scale_x-1)/scale_x;
    49                 rows=(max_y-min_y+scale_y-1)/scale_y;
    50                 screen=new char[rows*columns];
    51                 memset(screen,' ',rows*columns);
    52                 }
    53 
    54 ~Screen()
    55                 {
    56                 delete[] screen;
    57                 }
    58 
    59 void put(int x,int y,const char *str)
    60         {
    61         x=(x-min_x)/scale_x;
    62         y=(y-min_y)/scale_y;
    63         if (x<0) return;
    64         if (y<0) return;
    65         if (y>=rows) return;
    66         for(;*str;str++,x++)
    67                 {
    68                 if (x>=columns) return;
    69                 screen[columns*y+x]=*str;
     68                        if (x >= columns) return;
     69                        screen[columns * y + x] = *str;
    7070                }
    7171        }
    7272
    73 void print()
     73        void print()
    7474        {
    75         for(int y=0;y<rows;y++)
     75                for (int y = 0; y < rows; y++)
    7676                {
    77                 fwrite(&screen[columns*y],1,columns,stdout);
    78                 printf("\n");
     77                        fwrite(&screen[columns * y], 1, columns, stdout);
     78                        printf("\n");
    7979                }
    8080        }
    8181};
    8282
    83 int main(int argc,char*argv[])
     83int main(int argc, char*argv[])
    8484{
    85 LoggerToStdout messages_to_stdout(LoggerBase::Enable);
    86 PreconfiguredGenetics genetics;
     85        LoggerToStdout messages_to_stdout(LoggerBase::Enable);
     86        PreconfiguredGenetics genetics;
    8787
    88 if (argc<=1)
     88        if (argc <= 1)
    8989        {
    9090                puts("Parameters:\n"
    91                      " 1. Genotype (or - character indicating the genotype will be read from stdin)\n"
    92                      " 2. (Optional) layout type (the only useful layout is 2, which is the default, see nn_simple_layout.cpp");
    93           return 10;
     91                        " 1. Genotype (or - character indicating the genotype will be read from stdin)\n"
     92                        " 2. (Optional) layout type (the only useful layout is 2, which is the default, see nn_simple_layout.cpp");
     93                return 10;
    9494        }
    95 SString gen(argv[1]);
    96 if (!strcmp(gen.c_str(),"-"))
     95        SString gen(argv[1]);
     96        if (!strcmp(gen.c_str(), "-"))
    9797        {
    98         gen=0;
    99         StdioFILEDontClose in(stdin);
    100         loadSString(&in,gen);
     98                gen = 0;
     99                StdioFILEDontClose in(stdin);
     100                loadSString(&in, gen);
    101101        }
    102 int layout_type=2;
    103 if (argc>2) layout_type=atol(argv[2]);
    104 Geno g(gen);
    105 if (!g.isValid()) {puts("invalid genotype");return 5;}
    106 Model m(g);
    107 if (!m.getNeuroCount()) {puts("no neural network");return 1;}
    108 printf("%d neurons,",m.getNeuroCount());
     102        int layout_type = 2;
     103        if (argc > 2) layout_type = atol(argv[2]);
     104        Geno g(gen);
     105        if (!g.isValid()) { puts("invalid genotype"); return 5; }
     106        Model m(g, Model::SHAPE_UNKNOWN);
     107        if (!m.getNeuroCount()) { puts("no neural network"); return 1; }
     108        printf("%d neurons,", m.getNeuroCount());
    109109
    110 NNLayoutState_Model nn_layout(&m);
    111 struct NNLayoutFunction &nnfun=nn_layout_functions[layout_type];
    112 printf(" using layout type=%d (%s)\n",layout_type,nnfun.name);
    113 nnfun.doLayout(&nn_layout);
     110        NNLayoutState_Model nn_layout(&m);
     111        struct NNLayoutFunction &nnfun = nn_layout_functions[layout_type];
     112        printf(" using layout type=%d (%s)\n", layout_type, nnfun.name);
     113        nnfun.doLayout(&nn_layout);
    114114
    115 for(int i=0;i<nn_layout.GetElements();i++)
     115        for (int i = 0; i < nn_layout.GetElements(); i++)
    116116        {
    117         int *xywh=nn_layout.GetXYWH(i);
    118         printf("#%-3d %s\t%d,%d\t%dx%d\n",i,m.getNeuro(i)->getClassName().c_str(),
    119                xywh[0],xywh[1],xywh[2],xywh[3]);
     117                int *xywh = nn_layout.GetXYWH(i);
     118                printf("#%-3d %s\t%d,%d\t%dx%d\n", i, m.getNeuro(i)->getClassName().c_str(),
     119                        xywh[0], xywh[1], xywh[2], xywh[3]);
    120120        }
    121121
    122 Screen screen(*std::min_element(NNIter<0>::begin(&nn_layout),NNIter<0>::end(&nn_layout))-30,
    123               *std::max_element(NNIter<0>::begin(&nn_layout),NNIter<0>::end(&nn_layout))+70,
    124               *std::min_element(NNIter<1>::begin(&nn_layout),NNIter<1>::end(&nn_layout)),
    125               *std::max_element(NNIter<1>::begin(&nn_layout),NNIter<1>::end(&nn_layout))+30,
    126               10,35);
     122        Screen screen(*std::min_element(NNIter<0>::begin(&nn_layout), NNIter<0>::end(&nn_layout)) - 30,
     123                *std::max_element(NNIter<0>::begin(&nn_layout), NNIter<0>::end(&nn_layout)) + 70,
     124                *std::min_element(NNIter<1>::begin(&nn_layout), NNIter<1>::end(&nn_layout)),
     125                *std::max_element(NNIter<1>::begin(&nn_layout), NNIter<1>::end(&nn_layout)) + 30,
     126                10, 35);
    127127
    128 printf("===========================================\n");
    129 for(int i=0;i<nn_layout.GetElements();i++)
     128        printf("===========================================\n");
     129        for (int i = 0; i < nn_layout.GetElements(); i++)
    130130        {
    131         int *xywh=nn_layout.GetXYWH(i);
    132         SString label=SString::sprintf("%d:%s",i,m.getNeuro(i)->getClassName().c_str());
    133         screen.put(xywh[0],xywh[1],label.c_str());
     131                int *xywh = nn_layout.GetXYWH(i);
     132                SString label = SString::sprintf("%d:%s", i, m.getNeuro(i)->getClassName().c_str());
     133                screen.put(xywh[0], xywh[1], label.c_str());
    134134        }
    135 screen.print();
    136 printf("===========================================\n");
     135        screen.print();
     136        printf("===========================================\n");
    137137
    138138}
  • cpp/frams/_demos/neuro_test.cpp

    r391 r972  
    11// This file is a part of Framsticks SDK.  http://www.framsticks.com/
    2 // Copyright (C) 1999-2015  Maciej Komosinski and Szymon Ulatowski.
     2// Copyright (C) 1999-2020  Maciej Komosinski and Szymon Ulatowski.
    33// See LICENSE.txt for details.
    44
     
    1818#ifndef SDK_WITHOUT_FRAMS
    1919#include <frams/mech/creatmechobj.h>
    20 int CreatMechObject::modeltags_id=0;
    21 int CreatMechObject::mechtags_id=0;
     20int CreatMechObject::modeltags_id = 0;
     21int CreatMechObject::mechtags_id = 0;
    2222#endif
    2323
    24 ParamEntry creature_paramtab[]={0};
     24ParamEntry creature_paramtab[] = { 0 };
    2525
    2626#ifdef VEYETEST
     
    3333#define LEARNINGSTEPS 50
    3434
    35 void veyeStep(Model &m,int step)
     35void veyeStep(Model &m, int step)
    3636{
    37   static float angle=0;
     37        static float angle = 0;
    3838
    39   NeuroNetImpl::getImpl(m.getNeuro(N_Mode))->setState(step>=LEARNINGSTEPS); //0 (learning) or 1 (normal)
     39        NeuroNetImpl::getImpl(m.getNeuro(N_Mode))->setState(step >= LEARNINGSTEPS); //0 (learning) or 1 (normal)
    4040
    41         NeuroImpl *ni=NeuroNetImpl::getImpl(m.getNeuro(N_VEye));
    42   ((NI_VectorEye*)ni)->relpos.y=0;
    43   ((NI_VectorEye*)ni)->relpos.z=0;
    44   if (NeuroNetImpl::getImpl(m.getNeuro(N_Mode))->getNewState()<0.5)
    45   { //learning
    46     ((NI_VectorEye*)ni)->relpos.x=5.0*sin(2*M_PI*step/LEARNINGSTEPS);
    47   }
    48   else
    49   { //VMotor controls location of VEye
    50     angle+=NeuroNetImpl::getImpl(m.getNeuro(N_VMotor))->getState();
    51     angle=fmod((double)angle,M_PI*2.0);
    52     ((NI_VectorEye*)ni)->relpos.x=5*sin(angle);
    53   }
     41        NeuroImpl *ni = NeuroNetImpl::getImpl(m.getNeuro(N_VEye));
     42        ((NI_VectorEye*)ni)->relpos.y = 0;
     43        ((NI_VectorEye*)ni)->relpos.z = 0;
     44        if (NeuroNetImpl::getImpl(m.getNeuro(N_Mode))->getNewState() < 0.5)
     45        { //learning
     46                ((NI_VectorEye*)ni)->relpos.x = 5.0 * sin(2 * M_PI * step / LEARNINGSTEPS);
     47        }
     48        else
     49        { //VMotor controls location of VEye
     50                angle += NeuroNetImpl::getImpl(m.getNeuro(N_VMotor))->getState();
     51                angle = fmod((double)angle, M_PI * 2.0);
     52                ((NI_VectorEye*)ni)->relpos.x = 5 * sin(angle);
     53        }
    5454
    55   NeuroNetImpl::getImpl(m.getNeuro(N_Fitness))->setState(angle); //wymaga poprawy
    56   //oraz trzeba przemyslec kolejnosc get/set'ow neuronow zeby sygnal sie dobrze propagowal.
     55        NeuroNetImpl::getImpl(m.getNeuro(N_Fitness))->setState(angle); //wymaga poprawy
     56        //oraz trzeba przemyslec kolejnosc get/set'ow neuronow zeby sygnal sie dobrze propagowal.
    5757}
    5858#endif
    5959
    60 int main(int argc,char*argv[])
     60int main(int argc, char*argv[])
    6161{
    62 LoggerToStdout messages_to_stdout(LoggerBase::Enable);
    63 PreconfiguredGenetics genetics;
     62        LoggerToStdout messages_to_stdout(LoggerBase::Enable);
     63        PreconfiguredGenetics genetics;
    6464
    65 if (argc<=1)
     65        if (argc <= 1)
    6666        {
    6767                puts("Parameters: <genotype> [number of simulation steps]");
    68           return 10;
     68                return 10;
    6969        }
    70 SString gen(argv[1]);
    71 if (!strcmp(gen.c_str(),"-"))
     70        SString gen(argv[1]);
     71        if (!strcmp(gen.c_str(), "-"))
    7272        {
    73         gen=0;
    74         StdioFILEDontClose in(stdin);
    75         loadSString(&in,gen);
     73                gen = 0;
     74                StdioFILEDontClose in(stdin);
     75                loadSString(&in, gen);
    7676        }
    77 Geno g(gen);
    78 if (!g.isValid()) {puts("invalid genotype");return 5;}
    79 Model m(g);
    80 if (!m.getNeuroCount()) {puts("no neural network");return 1;}
    81 printf("%d neurons,",m.getNeuroCount());
    82 NeuroFactory neurofac;
    83 neurofac.setStandardImplementation();
    84 NeuroNetConfig nn_config(&neurofac);
    85 NeuroNetImpl *nn=new NeuroNetImpl(m,nn_config);
    86 int i; Neuro *n;
    87 if (!nn->getErrorCount()) printf(" no errors\n");
    88 else
     77        Geno g(gen);
     78        if (!g.isValid()) { puts("invalid genotype"); return 5; }
     79        Model m(g, Model::SHAPE_UNKNOWN);
     80        if (!m.getNeuroCount()) { puts("no neural network"); return 1; }
     81        printf("%d neurons,", m.getNeuroCount());
     82        NeuroFactory neurofac;
     83        neurofac.setStandardImplementation();
     84        NeuroNetConfig nn_config(&neurofac);
     85        NeuroNetImpl *nn = new NeuroNetImpl(m, nn_config);
     86        int i; Neuro *n;
     87        if (!nn->getErrorCount()) printf(" no errors\n");
     88        else
    8989        {
    90         printf(" %d errors:",nn->getErrorCount());
    91         int no_impl=0; SString no_impl_names;
    92         int init_err=0; SString init_err_names;
    93         for(i=0;i<m.getNeuroCount();i++)
     90                printf(" %d errors:", nn->getErrorCount());
     91                int no_impl = 0; SString no_impl_names;
     92                int init_err = 0; SString init_err_names;
     93                for (i = 0; i < m.getNeuroCount(); i++)
    9494                {
    95                 n=m.getNeuro(i);
    96                 NeuroImpl *ni=NeuroNetImpl::getImpl(n);
    97                 if (!ni)
     95                        n = m.getNeuro(i);
     96                        NeuroImpl *ni = NeuroNetImpl::getImpl(n);
     97                        if (!ni)
    9898                        {
    99                         if (no_impl) no_impl_names+=',';
    100                         no_impl_names+=SString::sprintf("#%d.%s",i,n->getClassName().c_str());
    101                         no_impl++;
     99                                if (no_impl) no_impl_names += ',';
     100                                no_impl_names += SString::sprintf("#%d.%s", i, n->getClassName().c_str());
     101                                no_impl++;
    102102                        }
    103                 else if (ni->status==NeuroImpl::InitError)
     103                        else if (ni->status == NeuroImpl::InitError)
    104104                        {
    105                         if (init_err) init_err_names+=',';
    106                         init_err_names+=SString::sprintf("#%d.%s",i,n->getClassName().c_str());
    107                         init_err++;
     105                                if (init_err) init_err_names += ',';
     106                                init_err_names += SString::sprintf("#%d.%s", i, n->getClassName().c_str());
     107                                init_err++;
    108108                        }
    109109                }
     110                printf("\n");
     111                if (no_impl) printf("%d x missing implementation (%s)\n", no_impl, no_impl_names.c_str());
     112                if (init_err) printf("%d x failed initialization (%s)\n", init_err, init_err_names.c_str());
     113        }
     114        int steps = 1;
     115        if (argc > 2) steps = atol(argv[2]);
     116        int st;
     117        printf("step");
     118        for (i = 0; i < m.getNeuroCount(); i++)
     119        {
     120                n = m.getNeuro(i);
     121                printf("\t#%d.%s", i, n->getClassName().c_str());
     122        }
    110123        printf("\n");
    111         if (no_impl) printf("%d x missing implementation (%s)\n",no_impl,no_impl_names.c_str());
    112         if (init_err) printf("%d x failed initialization (%s)\n",init_err,init_err_names.c_str());
    113         }
    114 int steps=1;
    115 if (argc>2) steps=atol(argv[2]);
    116 int st;
    117 printf("step");
    118 for(i=0;i<m.getNeuroCount();i++)
    119         {
    120         n=m.getNeuro(i);
    121         printf("\t#%d.%s",i,n->getClassName().c_str());
    122         }
    123 printf("\n");
    124 for(st=0;st<=steps;st++)
     124        for (st = 0; st <= steps; st++)
    125125        {
    126126#ifdef VEYETEST
    127   veyeStep(m,st);
     127                veyeStep(m, st);
    128128#endif
    129         printf("%d",st);
    130         for(i=0;i<m.getNeuroCount();i++)
     129                printf("%d", st);
     130                for (i = 0; i < m.getNeuroCount(); i++)
    131131                {
    132                 n=m.getNeuro(i);
    133                 printf("\t%g",n->state);
     132                        n = m.getNeuro(i);
     133                        printf("\t%g", n->state);
    134134                }
    135         printf("\n");
    136         nn->simulateNeuroNet();
     135                printf("\n");
     136                nn->simulateNeuroNet();
    137137        }
    138 neurofac.freeImplementation();
     138        neurofac.freeImplementation();
    139139}
  • cpp/frams/_demos/shapeconvert.cpp

    r546 r972  
    11// This file is a part of Framsticks SDK.  http://www.framsticks.com/
    2 // Copyright (C) 1999-2016  Maciej Komosinski and Szymon Ulatowski.
     2// Copyright (C) 1999-2020  Maciej Komosinski and Szymon Ulatowski.
    33// See LICENSE.txt for details.
    44
     
    4646                if (ar[0] == '-')
    4747                        switch (ar[1])
    48                 {
     48                        {
    4949                        case 's': shape = (Part::Shape)atol(ar + 2);
    5050                                if ((shape != Part::SHAPE_ELLIPSOID) && (shape != Part::SHAPE_CUBOID) && (shape != Part::SHAPE_CYLINDER))
     
    5656                        case 't': thickness = atof(ar + 2); break;
    5757                        case 'h': puts("Usage: shapeconvert [-sSHAPE] [-tTHICKNESS] [genotype_or_stdin]\n\tSHAPE: 1=ellipsoid, 2=cuboid, 3(default)=cylinder\n\tTHICKNESS: used for Part.sy/sz (default=0.2)"); break;
    58                 }
     58                        }
    5959                else
    6060                        if (!gen_arg)
     
    6767                loadSString(VirtFILE::Vstdin, gen);
    6868        Geno g(gen);
    69         Model m(g);
     69        Model m(g, Model::SHAPE_UNKNOWN);
    7070
    7171        if (!m.isValid())
  • cpp/frams/genetics/geno.cpp

    r955 r972  
    2424}
    2525
     26bool Geno::formatIsOneOf(const SString& format, const SString& format_list)
     27{
     28        if (strchr(format_list.c_str(), ',') == NULL)
     29                return format == format_list;
     30        else
     31        {
     32                SString item; int pos = 0;
     33                while (format_list.getNextToken(pos, item, ','))
     34                        if (item == format)
     35                                return true;
     36        }
     37        return false;
     38}
     39
    2640const SString Geno::INVALID_FORMAT = "invalid";
    2741const SString Geno::UNKNOWN_FORMAT = "";
     42const SString Geno::F0_FORMAT_LIST = "0,0s";
     43
     44bool Geno::isF0Format(const SString& format_list)
     45{
     46        if (strchr(format_list.c_str(), ',') == NULL)
     47                return formatIsOneOf(format_list, F0_FORMAT_LIST);
     48        SString item; int pos = 0;
     49        while (format_list.getNextToken(pos, item, ','))
     50                if (!formatIsOneOf(item, F0_FORMAT_LIST))
     51                        return false;
     52        return true;
     53}
    2854
    2955void Geno::init(const SString& genstring, const SString& genformat, const SString& genname, const SString& comment)
     
    4167{
    4268        SString format = trim(input);
    43         if (format.len() == 0 || strContainsOneOf(format.c_str(), " \r\n\t"))
     69        if (format.length() == 0 || strContainsOneOf(format.c_str(), " \r\n\t"))
    4470                return Geno::INVALID_FORMAT;
    4571        return format;
     
    7399                                        genformat = trimAndValidateFormat(genstring.substr(2));
    74100                                        gencopy = "";
    75                                         mapinshift = genstring.len();
     101                                        mapinshift = genstring.length();
    76102                                }
    77103                                break;
     
    88114                                        genformat = trimAndValidateFormat(genstring.substr(2));
    89115                                        gencopy = "";
    90                                         mapinshift = genstring.len();
     116                                        mapinshift = genstring.length();
    91117                                }
    92118                                break;
     
    95121                        {
    96122                                SString cut;
    97                                 if (error_end < 0) error_end = genstring.len();
     123                                if (error_end < 0) error_end = genstring.length();
    98124                                static const int MAX_ERROR = 20;
    99125                                if (error_end > MAX_ERROR)
     
    104130                                if (lf >= 0) { if ((lf > 0) && (cut[lf - 1] == '\r')) lf--; cut = cut.substr(0, lf); }
    105131                                sstringQuote(cut);
    106                                 logPrintf("Geno", "init", LOG_ERROR, "Invalid genotype format declaration: '%s'%s", cut.c_str(), name.len() ? SString::sprintf(" in '%s'", name.c_str()).c_str() : "");
     132                                logPrintf("Geno", "init", LOG_ERROR, "Invalid genotype format declaration: '%s'%s", cut.c_str(), name.length() ? SString::sprintf(" in '%s'", name.c_str()).c_str() : "");
    107133                        }
    108134
     
    212238int Geno::mapGenToString(int genpos) const
    213239{
    214         if (genpos > gen.len()) return -2;
     240        if (genpos > gen.length()) return -2;
    215241        if (genpos < 0) return -1;
    216242        return mapinshift + genpos;
     
    220246{
    221247        stringpos -= mapinshift;
    222         if (stringpos > gen.len()) return -2;
     248        if (stringpos > gen.length()) return -2;
    223249        if (stringpos < 0) return -1;
    224250        return stringpos;
     
    232258int ModelGenoValidator::testGenoValidity(Geno& g)
    233259{
    234         if (g.getFormat() == "0")
    235         {
    236                 Model mod(g);
     260        if (Geno::formatIsOneOf(g.getFormat(), Geno::F0_FORMAT_LIST))
     261        {
     262                Model mod(g, Model::SHAPE_UNKNOWN);
    237263                return mod.isValid();
    238264        }
     
    240266        {
    241267                bool converter_missing;
    242                 Geno f0geno = g.getConverted("0", NULL, false, &converter_missing);
     268                Geno f0geno = g.getConverted(Geno::F0_FORMAT_LIST, NULL, false, &converter_missing);
    243269                if (converter_missing)
    244270                        return -1;//no result
     
    250276{
    251277        if (isvalid >= 0) return;
    252         if (gen.len() == 0) { isvalid = 0; return; }
     278        if (gen.length() == 0) { isvalid = 0; return; }
    253279        if (format == INVALID_FORMAT) { isvalid = 0; return; }
    254280        Validators* vals = getValidators();
     
    309335}
    310336
    311 Geno Geno::getConverted(SString otherformat, MultiMap *m, bool using_checkpoints, bool *converter_missing)
    312 {
    313         if (otherformat == getFormat()) { if (converter_missing) *converter_missing = false; return *this; }
     337Geno Geno::getConverted(SString otherformat_list, MultiMap *m, bool using_checkpoints, bool *converter_missing)
     338{
     339        if (formatIsOneOf(getFormat(), otherformat_list)) { if (converter_missing) *converter_missing = false; return *this; }
    314340#ifndef NO_GENOCONVMANAGER
    315341        GenoConvManager *converters = getConverters();
    316342        if (converters)
    317343        {
    318                 if ((otherformat == "0") && (!m) && (!using_checkpoints))
     344                if ((isF0Format(otherformat_list)) && (!m) && (!using_checkpoints))
    319345                {
    320346                        if (!f0gen)
    321                                 f0gen = new Geno(converters->convert(*this, otherformat, NULL, using_checkpoints, converter_missing));
     347                                f0gen = new Geno(converters->convert(*this, otherformat_list, NULL, using_checkpoints, converter_missing));
    322348                        else
    323349                        {
     
    327353                }
    328354                else
    329                         return converters->convert(*this, otherformat, m, using_checkpoints, converter_missing);
     355                        return converters->convert(*this, otherformat_list, m, using_checkpoints, converter_missing);
    330356        }
    331357#endif
    332358        if (converter_missing) *converter_missing = true;
    333         return (otherformat == getFormat()) ? *this : Geno("", "", "", "GenConvManager not available");
     359        return (formatIsOneOf(getFormat(), otherformat_list)) ? *this : Geno("", "", "", "GenConvManager not available");
    334360}
    335361
  • cpp/frams/genetics/geno.h

    r955 r972  
    129129        static GenoConvManager* useConverters(GenoConvManager* gcm);
    130130        static GenoConvManager* getConverters();
     131
     132        static bool formatIsOneOf(const SString& format, const SString& format_list);
     133        static bool isF0Format(const SString& format_list);
     134        static const SString F0_FORMAT_LIST;
    131135};
    132136
  • cpp/frams/genetics/genoconv.cpp

    r955 r972  
    123123/// (can be NULL if you don't need this information)
    124124
    125 GenoConverter **GenoConvManager::getPath(const SString& in, const SString& out, GenoConverter **path, int maxlen, int *mapavailable)
     125GenoConverter **GenoConvManager::getPath(const SString& in_format, const SString& out_format_list, GenoConverter **path, int maxlen, int *mapavailable)
    126126{
    127127        if (!maxlen) return 0;
     
    130130        for (; gk = (GenoConverter*)converters(i); i++)
    131131        {
    132                 if ((gk->enabled) && (gk->in_format == in))
     132                if ((gk->enabled) && (gk->in_format == in_format))
    133133                {
    134134                        *path = gk;
    135                         if (gk->out_format == out)
     135                        if (Geno::formatIsOneOf(gk->out_format, out_format_list))
    136136                        {
    137137                                if (mapavailable)
     
    142142                        {
    143143                                int mapavail;
    144                                 GenoConverter **ret = getPath(gk->out_format, out, path + 1, maxlen - 1, &mapavail);
     144                                GenoConverter **ret = getPath(gk->out_format, out_format_list, path + 1, maxlen - 1, &mapavail);
    145145                                if (ret)
    146146                                {
     
    155155}
    156156
    157 Geno GenoConvManager::convert(Geno &in, SString format, MultiMap *map, bool using_checkpoints, bool *converter_missing)
    158 {
    159         if (in.getFormat() == format) { if (converter_missing) *converter_missing = false; return in; }
     157Geno GenoConvManager::convert(Geno &in, SString format_list, MultiMap *map, bool using_checkpoints, bool *converter_missing)
     158{
     159        if (Geno::formatIsOneOf(in.getFormat(), format_list))
     160        {
     161                if (converter_missing) *converter_missing = false; return in;
     162        }
    160163        GenoConverter *path[10];
    161164        int dep;
     
    164167        int mapavail;
    165168        for (dep = 1; dep < (int)sizeof(path); dep++) //iterative deepening
    166                 if (ret = getPath(in.getFormat(), format, path, dep, &mapavail)) break;
     169                if (ret = getPath(in.getFormat(), format_list, path, dep, &mapavail)) break;
    167170        if (!ret) { if (converter_missing) *converter_missing = true; return Geno("", Geno::INVALID_FORMAT, "", "converter not found"); }
    168171        if (converter_missing) *converter_missing = false;
    169172        if (!map) mapavail = 0;
    170173        GenoConverter **t = path;
    171         SString tmp;
     174        SString tmp, out_format;
    172175        tmp = in.getGenes();
    173176        MultiMap lastmap, tmpmap;
     
    177180                GenoConverter *gk = *t;
    178181                tmp = gk->convert(tmp, mapavail ? &tmpmap : 0, using_checkpoints);
    179                 if (!tmp.len())
     182                out_format = gk->out_format;
     183                if (!tmp.length())
    180184                {
    181185                        string t = ssprintf("f%s->f%s conversion failed (%s)", gk->in_format.c_str(), gk->out_format.c_str(), gk->name);
     
    200204        if (map)
    201205                *map = lastmap;
    202         return Geno(tmp, format, in.getName(), in.getComment());
    203 }
     206        return Geno(tmp, out_format, in.getName(), in.getComment());
     207}
  • cpp/frams/genetics/genoconv.h

    r955 r972  
    7777        /// make a genotype in other format. genotype will be invalid
    7878        /// if GenoConvManager cannot convert it.
    79         Geno convert(Geno &in, SString format, MultiMap *map = 0, bool using_checkpoints = false, bool *converter_missing = NULL);
     79        Geno convert(Geno &in, SString format_list, MultiMap *map = 0, bool using_checkpoints = false, bool *converter_missing = NULL);
    8080        /// register GenoConverter, the added object will be automatically deleted when GenoConvManager is destructed (call removeConverter() if this is not desirable)
    8181        void addConverter(GenoConverter *conv);
  • cpp/frams/model/model.cpp

    r955 r972  
    11// This file is a part of Framsticks SDK.  http://www.framsticks.com/
    2 // Copyright (C) 1999-2019  Maciej Komosinski and Szymon Ulatowski.
     2// Copyright (C) 1999-2020  Maciej Komosinski and Szymon Ulatowski.
    33// See LICENSE.txt for details.
    44
     
    1111#define F0_CHECKPOINT_LINE "checkpoint:"
    1212
    13 Model::Model()
     13Model::Model(ShapeType sh)
    1414{
    1515        autobuildmaps = false;
    16         init();
    17 }
    18 
    19 void Model::init()
     16        init(sh);
     17}
     18
     19void Model::init(ShapeType sh)
    2020{
    2121        partmappingchanged = 0;
     
    3030        f0genoknown = 1;
    3131        shape = SHAPE_UNKNOWN;
     32        declared_shape = sh;
     33}
     34
     35void Model::declareShapeType(ShapeType sh)
     36{
     37        declared_shape = sh;
    3238}
    3339
     
    5157        f0genoknown = 0;
    5258        shape = mod.shape;
     59        declared_shape = mod.declared_shape;
    5360        startenergy = mod.startenergy;
    5461        modelfromgenotype = mod.modelfromgenotype;
     
    93100
    94101
    95 Model::Model(const Geno &src, bool buildmaps, bool _using_checkpoints, bool _is_checkpoint)
     102Model::Model(const Geno &src, ShapeType st, bool buildmaps, bool _using_checkpoints, bool _is_checkpoint)
    96103        :autobuildmaps(buildmaps)
    97104{
    98         init(src, _using_checkpoints, _is_checkpoint);
     105        init(src, st, _using_checkpoints, _is_checkpoint);
    99106}
    100107
     
    110117        :autobuildmaps(buildmaps)
    111118{
    112         init();
     119        init(mod.declared_shape);
    113120        open(_using_checkpoints, _is_checkpoint);
    114121        internalCopy(mod);
     
    123130}
    124131
    125 void Model::init(const Geno &src, bool _using_checkpoints, bool _is_checkpoint)
    126 {
    127         init();
     132void Model::init(const Geno &src, ShapeType sh, bool _using_checkpoints, bool _is_checkpoint)
     133{
     134        init(sh);
    128135        using_checkpoints = _using_checkpoints;
    129136        is_checkpoint = _is_checkpoint;
     
    162169        delMap();
    163170        delF0Map();
    164         init();
     171        init(declared_shape);
    165172        geno = Geno();
    166173        f0geno = Geno();
     
    333340        f0warnposition = -1;
    334341        MultiMap *convmap = autobuildmaps ? new MultiMap() : NULL;
    335         f0geno = (geno.getFormat() == "0") ? geno : geno.getConverted("0", convmap, using_checkpoints);
     342        if (declared_shape == SHAPE_UNKNOWN)
     343                f0geno = geno.getConverted(Geno::F0_FORMAT_LIST, convmap, using_checkpoints);
     344        else
     345                f0geno = geno.getConverted(genoFormatForShapeType(declared_shape), convmap, using_checkpoints);
    336346        f0genoknown = 1;
    337347        if (f0geno.isInvalid())
     
    467477        modelparam.select(this);
    468478        modelparam.saveSingleLine(mod_props, handle_defaults ? &defaultmodel : NULL, true, !handle_defaults);
    469         if (mod_props.len() > 1) //are there any non-default values? ("\n" is empty)
     479        if (mod_props.length() > 1) //are there any non-default values? ("\n" is empty)
    470480        {
    471481                gen += "m:";
     
    476486        {
    477487                partparam.select(p);
    478                 len = gen.len();
     488                len = gen.length();
    479489                gen += "p:";
    480490                partparam.saveSingleLine(gen, handle_defaults ? &defaultpart : NULL, true, !handle_defaults);
    481491                if (map)
    482                         map->add(len, gen.len() - 1, partToMap(i));
     492                        map->add(len, gen.length() - 1, partToMap(i));
    483493        }
    484494        for (i = 0; j = (Joint *)joints(i); i++)
    485495        {
    486496                jointparam.select(j);
    487                 len = gen.len();
     497                len = gen.length();
    488498                jointparam.setParamTab(j->usedelta ? f0_joint_paramtab : f0_nodeltajoint_paramtab);
    489499                gen += "j:";
    490500                jointparam.saveSingleLine(gen, handle_defaults ? &defaultjoint : NULL, true, !handle_defaults);
    491501                if (map)
    492                         map->add(len, gen.len() - 1, jointToMap(i));
     502                        map->add(len, gen.length() - 1, jointToMap(i));
    493503        }
    494504        for (i = 0; n = (Neuro *)neurons(i); i++)
    495505        {
    496506                neuroparam.select(n);
    497                 len = gen.len();
     507                len = gen.length();
    498508                gen += "n:";
    499509                neuroparam.saveSingleLine(gen, handle_defaults ? &defaultneuro : NULL, true, !handle_defaults);
    500510                if (map)
    501                         map->add(len, gen.len() - 1, neuroToMap(i));
     511                        map->add(len, gen.length() - 1, neuroToMap(i));
    502512        }
    503513        for (a = 0; a < neurons.size(); a++)
     
    526536                                nc.info = **s;
    527537                        connparam.select(&nc);
    528                         len = gen.len();
     538                        len = gen.length();
    529539                        gen += "c:";
    530540                        connparam.saveSingleLine(gen, handle_defaults ? &defaultconn : NULL, true, !handle_defaults);
    531541                        if (map)
    532                                 map->add(len, gen.len() - 1, neuroToMap(n->refno));
     542                                map->add(len, gen.length() - 1, neuroToMap(n->refno));
    533543                }
    534544        }
     
    541551        }
    542552
    543         g = Geno(gen.c_str(), '0');
     553        g = Geno(gen.c_str(), genoFormatForShapeType(getShapeType()), "", "");
     554}
     555
     556SString Model::genoFormatForShapeType(ShapeType st)
     557{
     558        switch (st)
     559        {
     560        case SHAPE_BALL_AND_STICK:
     561                return "0";
     562        case SHAPE_SOLIDS:
     563                return "0s";
     564        default:
     565                return Geno::INVALID_FORMAT;
     566        }
     567}
     568
     569Model::ShapeType Model::shapeTypeForGenoFormat(const SString& format)
     570{
     571        if (format == "0")
     572                return SHAPE_BALL_AND_STICK;
     573        else if (format == "0s")
     574                return SHAPE_SOLIDS;
     575        else
     576                return SHAPE_UNKNOWN;
     577
     578}
     579
     580const char* Model::getShapeTypeName(ShapeType sh)
     581{
     582        switch (sh)
     583        {
     584        case SHAPE_BALL_AND_STICK: return "ball-and-stick";
     585        case SHAPE_SOLIDS: return "solid shapes";
     586        case SHAPE_UNKNOWN: return "unknown";
     587
     588        case SHAPE_ILLEGAL:
     589        default:
     590                return "illegal";
     591        }
    544592}
    545593
     
    653701        if (result < 0)
    654702        {
    655                 if (error_message.len() == 0) // generic error when no detailed message is available
     703                if (error_message.length() == 0) // generic error when no detailed message is available
    656704                        error_message = "Invalid f0 code";
    657705                if (line_num > 0)
     
    731779                {
    732780                        // default class for unparented units: standard neuron
    733                         if (nu->getClassName().len() == 0) nu->setClassName("N");
     781                        if (nu->getClassName().length() == 0) nu->setClassName("N");
    734782                }
    735783                /*
     
    832880SString Model::nameForErrors() const
    833881{
    834         if (geno.getName().len() > 0)
     882        if (geno.getName().length() > 0)
    835883                return SString::sprintf(" in '%s'", geno.getName().c_str());
    836884        return SString::empty();
     
    10611109        if (shape == SHAPE_ILLEGAL)
    10621110                ret = 0;
     1111        else if ((declared_shape != SHAPE_UNKNOWN) && (declared_shape != shape))
     1112        {
     1113                logPrintf("Model", "internalCheck", LOG_ERROR, "Model shape type '%s' does not match the declared type '%s'", getShapeTypeName(shape), getShapeTypeName(declared_shape));
     1114                ret = 0;
     1115        }
     1116
    10631117        return ret;
    10641118}
  • cpp/frams/model/model.h

    r935 r972  
    102102protected:
    103103        ShapeType shape;
     104        ShapeType declared_shape;
    104105
    105106        SString nameForErrors() const;
    106107        int internalcheck(CheckType check);
    107108
    108         void init(const Geno &srcgen, bool _using_checkpoints, bool _is_checkpoint);
    109         void init();
     109        void init(const Geno &srcgen, ShapeType sh, bool _using_checkpoints, bool _is_checkpoint);
     110        void init(ShapeType sh);
    110111
    111112        void delMap();
     
    136137        bool isUsingCheckpoints() const { return using_checkpoints; }
    137138        bool isCheckpoint() const { return is_checkpoint; }
     139        static SString genoFormatForShapeType(ShapeType st);
     140        static ShapeType shapeTypeForGenoFormat(const SString& format);
     141        static const char* getShapeTypeName(ShapeType sh);
    138142
    139143        void updateRefno(); // set ::refno for all elements
     
    150154        ModelUserTags userdata;
    151155
    152         /// Create empty model with invalid empty genotype
    153         Model();
     156        /// Create empty model with invalid empty genotype, declaring the shape type for later operations
     157        Model(ShapeType sh = SHAPE_UNKNOWN);
     158
     159        /// Change the declared shape type of the Model
     160        void declareShapeType(ShapeType sh);
    154161
    155162        /** Create a model based on provided genotype
     
    158165           @see getMap()
    159166           */
    160         Model(const Geno &src, bool buildmaps = false, bool _using_checkpoints = false, bool _is_checkpoint = false);
     167        Model(const Geno &src, ShapeType sh, bool buildmaps = false, bool _using_checkpoints = false, bool _is_checkpoint = false);
    161168        Model(const Model &mod, bool buildmaps = false, bool _using_checkpoints = false, bool _is_checkpoint = false);
    162169        /** duplicate the model.
  • cpp/frams/model/modelobj.cpp

    r732 r972  
    5858void ModelObj::p_newfromstring(ExtValue *args, ExtValue *ret)
    5959{
    60         *ret = makeDynamicObject(new Model(Geno(args[0].getString())));
     60        *ret = makeDynamicObject(new Model(Geno(args[0].getString()), Model::SHAPE_UNKNOWN));
    6161}
    6262
     
    6565        Geno *g = GenoObj::fromObject(args[0].getObject());
    6666        if (g)
    67                 *ret = makeDynamicObject(new Model(*g));
     67                *ret = makeDynamicObject(new Model(*g, Model::SHAPE_UNKNOWN));
    6868        else
    6969                ret->setEmpty();
     
    7474        Model *m = NULL;
    7575        if (args[0].getType() == TString)
    76                 m = new Model(Geno(args[0].getString()), false, true);
     76                m = new Model(Geno(args[0].getString()), Model::SHAPE_UNKNOWN, false, true);
    7777        else
    7878        {
    7979                Geno *g = GenoObj::fromObject(args[0].getObject(), false);
    8080                if (g)
    81                         m = new Model(*g, false, true);
     81                        m = new Model(*g, Model::SHAPE_UNKNOWN, false, true);
    8282                else
    8383                        logPrintf("Model", "newWithCheckpoints", LOG_ERROR, "Geno or string expected, %s found", args[0].typeDescription().c_str());
  • cpp/frams/model/modelparts.h

    r952 r972  
    3434{
    3535public:
    36         enum ShapeType { SHAPE_BALL_AND_STICK, SHAPE_SOLIDS, SHAPE_UNKNOWN, SHAPE_ILLEGAL };
     36        enum ShapeType { SHAPE_BALL_AND_STICK = 0, SHAPE_SOLIDS = 1, SHAPE_UNKNOWN, SHAPE_ILLEGAL }; ///< 0 and 1 have special significance - these values allow for bit operations.
    3737};
    3838
  • cpp/frams/model/similarity/simil_model.cpp

    r877 r972  
    11// This file is a part of Framsticks SDK.  http://www.framsticks.com/
    2 // Copyright (C) 1999-2019  Maciej Komosinski and Szymon Ulatowski.
     2// Copyright (C) 1999-2020  Maciej Komosinski and Szymon Ulatowski.
    33// See LICENSE.txt for details.
    44
     
    122122
    123123        // assign matching function
    124         int (ModelSimil::* pfMatchingFunction) () = NULL;
     124        int (ModelSimil:: * pfMatchingFunction) () = NULL;
    125125
    126126        pfMatchingFunction = &ModelSimil::MatchPartsGeometry;
     
    534534                return NULL;
    535535        }
    536         Model *m = new Model(*g);
     536        Model *m = new Model(*g, Model::SHAPE_UNKNOWN);
    537537        if (!m->isValid())
    538538        {
     
    20582058                        {
    20592059                                if (geo)
    2060                                         dist[i*bigger + j] += m_adFactors[3] * m_aPositions[1 - m_iSmaller][i].length();
     2060                                        dist[i * bigger + j] += m_adFactors[3] * m_aPositions[1 - m_iSmaller][i].length();
    20612061                                else
    2062                                         dist[i*bigger + j] = m_adFactors[1] * m_aDegrees[1 - m_iSmaller][i][DEGREE] + m_adFactors[2] * m_aDegrees[1 - m_iSmaller][i][NEURONS];
     2062                                        dist[i * bigger + j] = m_adFactors[1] * m_aDegrees[1 - m_iSmaller][i][DEGREE] + m_adFactors[2] * m_aDegrees[1 - m_iSmaller][i][NEURONS];
    20632063                        }
    20642064                        // compute distance between parts
     
    20662066                        {
    20672067                                if (geo)
    2068                                         dist[i*bigger + j] += m_adFactors[3] * m_aPositions[1 - m_iSmaller][i].distanceTo(m_aPositions[m_iSmaller][j]);
     2068                                        dist[i * bigger + j] += m_adFactors[3] * m_aPositions[1 - m_iSmaller][i].distanceTo(m_aPositions[m_iSmaller][j]);
    20692069                                else
    2070                                         dist[i*bigger + j] = m_adFactors[1] * abs(m_aDegrees[1 - m_iSmaller][i][DEGREE] - m_aDegrees[m_iSmaller][j][DEGREE])
     2070                                        dist[i * bigger + j] = m_adFactors[1] * abs(m_aDegrees[1 - m_iSmaller][i][DEGREE] - m_aDegrees[m_iSmaller][j][DEGREE])
    20712071                                        + m_adFactors[2] * abs(m_aDegrees[1 - m_iSmaller][i][NEURONS] - m_aDegrees[m_iSmaller][j][NEURONS]);
    20722072                        }
     
    21042104        int nBigger = m_Mod[1 - m_iSmaller]->getPartCount();
    21052105
    2106         double* partsDistances = new double[nBigger*nBigger]();
     2106        double* partsDistances = new double[nBigger * nBigger]();
    21072107        FillPartsDistances(partsDistances, nBigger, nSmaller, false);
    21082108        int *assignment = new int[nBigger]();
     
    21382138                        // - models (m_Mod) exist and are available
    21392139                        // - all properties are created and available (m_aDegrees and m_aPositions)
    2140                         double* tmpPartsDistances = new double[nBigger*nBigger]();
     2140                        double* tmpPartsDistances = new double[nBigger * nBigger]();
    21412141                        std::copy(partsDistances, partsDistances + nBigger * nBigger, tmpPartsDistances);
    21422142                        // recompute geometric properties according to the transformation iTransform
  • cpp/frams/userinput/modelcheckpoints.cpp

    r741 r972  
    11// This file is a part of Framsticks SDK.  http://www.framsticks.com/
    2 // Copyright (C) 1999-2018  Maciej Komosinski and Szymon Ulatowski.
     2// Copyright (C) 1999-2020  Maciej Komosinski and Szymon Ulatowski.
    33// See LICENSE.txt for details.
    44
     
    4545        freeModel();
    4646        if (g != NULL)
    47                 mod = new Model(*g, true, false);
     47                mod = new Model(*g, Model::SHAPE_UNKNOWN, true, false);
    4848        toguiCheckpoints(use_checkpoints ? EnabledUnknown : Disabled, 1, 1);
    4949        int ret = model_view.showModel(mod);
     
    5858        {
    5959                if (p == current_value) return;
    60                 mod_checkpoints = new Model(mod->getGeno(), false, true);
     60                mod_checkpoints = new Model(mod->getGeno(), Model::SHAPE_UNKNOWN, false, true);
    6161                if (mod_checkpoints->getCheckpointCount() > 1)
    6262                {
  • cpp/frams/vm/classes/genoobj.cpp

    r955 r972  
    11// This file is a part of Framsticks SDK.  http://www.framsticks.com/
    2 // Copyright (C) 1999-2018  Maciej Komosinski and Szymon Ulatowski.
     2// Copyright (C) 1999-2020  Maciej Komosinski and Szymon Ulatowski.
    33// See LICENSE.txt for details.
    44
     
    6464void GenoObj::get_autoname(ExtValue *ret)
    6565{
    66         Model m(*this);
     66        Model m(*this, Model::SHAPE_UNKNOWN);
    6767        ret->setString(AutoName::makeName(m));
    6868}
     
    9797void GenoObj::get_f0genotype(ExtValue *ret)
    9898{
    99         ret->setString(getConverted('0').getGenes());
     99        ret->setString(getConverted(Geno::F0_FORMAT_LIST).getGenes());
    100100}
    101101
     
    105105        {
    106106                char ch = v.getInt();
    107                 return SString(&ch,1);
     107                return SString(&ch, 1);
    108108        }
    109109        if (v.getType() == TString)
     
    144144#ifdef __CODEGUARD__
    145145        static GenoObj static_genoobj;
    146         static Param static_genoparam(geno_paramtab,&static_genoobj);
     146        static Param static_genoparam(geno_paramtab, &static_genoobj);
    147147#else
    148148        static Param static_genoparam(geno_paramtab);
Note: See TracChangeset for help on using the changeset viewer.