Changeset 726 for cpp/frams/genetics


Ignore:
Timestamp:
01/19/18 19:37:43 (6 years ago)
Author:
Maciej Komosinski
Message:
  • Changed Model::singleStepBuild() to Model::addFromString() to create model elements; the latter requires explicit indication of element type (P/J/N/C)
  • Removed old compatibility source (#ifdef MODEL_V1_COMPATIBLE) from f1->f0 converter and neuron definitions
Location:
cpp/frams/genetics
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • cpp/frams/genetics/f1/conv_f1.cpp

    r719 r726  
    111111        Builder builder(g, map ? 1 : 0);
    112112        builder.model.open();
    113         builder.grow(-1, g, Pt3D_0, stdprops, -1); // uses Model::singleStepBuild to create model elements
     113        builder.grow(-1, g, Pt3D_0, stdprops, -1); // uses Model::addFromString() to create model elements
    114114        if (builder.invalid) return SString();
    115115        builder.addPendingInputs();
     
    323323{
    324324        double len = min(2.0, c.length);
    325         sprintf(tmp, "j:p1=%ld,p2=%ld,dx=%lg,rx=%lg,ry=%lg,rz=%lg,stam=%lg,vr=%g,vg=%g,vb=%g",
     325        sprintf(tmp, "p1=%ld,p2=%ld,dx=%lg,rx=%lg,ry=%lg,rz=%lg,stam=%lg,vr=%g,vg=%g,vb=%g",
    326326                part1, part2, len, angle.x, angle.y, angle.z, c.stamina, c.cred, c.cgreen, c.cblue);
    327327        lastjoint_muscle_power = c.muscle_power;
    328         return model.singleStepBuild(tmp, makeRange(g));
     328        return model.addFromString(Model::JointType, tmp, makeRange(g));
    329329}
    330330
    331331int Builder::growPart(F1Props &c, const char *g)
    332332{
    333         sprintf(tmp, "p:dn=%lg,fr=%lg,ing=%lg,as=%lg,vs=%g,vr=%g,vg=%g,vb=%g",
     333        sprintf(tmp, "dn=%lg,fr=%lg,ing=%lg,as=%lg,vs=%g,vr=%g,vg=%g,vb=%g",
    334334                1.0 / c.weight, c.friction, c.ingestion, c.assimilation, c.visual_size, c.cred, c.cgreen, c.cblue);
    335         return model.singleStepBuild(tmp, makeRange(g));
     335        return model.addFromString(Model::PartType, tmp, makeRange(g));
    336336}
    337337
  • cpp/frams/genetics/f4/conv_f4.cpp

    r675 r726  
    178178                        // new part object for firstend
    179179                        // coordinates are left to be computed by Model
    180                         sprintf(tmpLine, "p:fr=%g,ing=%g,as=%g",
     180                        sprintf(tmpLine, "fr=%g,ing=%g,as=%g",
    181181                                /*1.0/C->P.mass,*/ C->P.friction, C->P.ingestion, C->P.assimilation
    182182                                //C->firstend.x, C->firstend.y, C->firstend.z
    183183                                );
    184                         partidx = singleStepBuild(tmpLine, &range);
     184                        partidx = addFromString(PartType, tmpLine, &range);
    185185                        if (partidx < 0) return -1;
    186186                        jj_p1_refno = partidx;
     
    194194                }
    195195                // new part object for lastend
    196                 sprintf(tmpLine, "p:fr=%g,ing=%g,as=%g",
     196                sprintf(tmpLine, "fr=%g,ing=%g,as=%g",
    197197                        //C->lastend.x, C->lastend.y, C->lastend.z
    198198                        /*"vol=" 1.0/C->P.mass,*/ C->P.friction, C->P.ingestion, C->P.assimilation
    199199                        );
    200                 partidx = singleStepBuild(tmpLine, &range);
     200                partidx = addFromString(PartType, tmpLine, &range);
    201201                if (partidx < 0) return -2;
    202202                C->p2_refno = partidx;
     
    207207                if ((jj_p1_refno < 0) || (jj_p1_refno >= getPartCount())) return -11;
    208208                if ((jj_p2_refno < 0) || (jj_p2_refno >= getPartCount())) return -12;
    209                 sprintf(tmpLine, "j:p1=%ld,p2=%ld,dx=%g,dy=0,dz=0,rx=%g,ry=0,rz=%g"\
     209                sprintf(tmpLine, "p1=%ld,p2=%ld,dx=%g,dy=0,dz=0,rx=%g,ry=0,rz=%g"\
    210210                        ",stam=%g",
    211211                        jj_p1_refno, jj_p2_refno,
     
    218218                        C->P.stamina
    219219                        );
    220                 partidx = singleStepBuild(tmpLine, &range);
     220                partidx = addFromString(JointType, tmpLine, &range);
    221221                if (partidx < 0) return -13;
    222222                C->joint_refno = partidx;
     
    230230                if ((p_refno < 0) || (p_refno >= getPartCount())) return -21;
    231231                // joint_refno is currently not used
    232                 sprintf(tmpLine, "n:p=%ld,d=\"N:in=%g,fo=%g,si=%g\"",
     232                sprintf(tmpLine, "p=%ld,d=\"N:in=%g,fo=%g,si=%g\"",
    233233                        p_refno,
    234234                        C->inertia, C->force, C->sigmo);
    235                 partidx = singleStepBuild(tmpLine, &range);
     235                partidx = addFromString(NeuronType, tmpLine, &range);
    236236                if (partidx < 0) return -22;
    237237                C->neuro_refno = partidx;
     
    241241                {
    242242                        if (1 == C->ctrl)
    243                                 sprintf(tmpLine, "n:j=%d,d=\"@:p=%g\"", C->dadlink->joint_refno, C->P.muscle_power);
     243                                sprintf(tmpLine, "j=%d,d=\"@:p=%g\"", C->dadlink->joint_refno, C->P.muscle_power);
    244244                        else
    245                                 sprintf(tmpLine, "n:j=%d,d=\"|:p=%g,r=%g\"", C->dadlink->joint_refno, C->P.muscle_power, C->mz);
    246                         partidx = singleStepBuild(tmpLine, &range);
     245                                sprintf(tmpLine, "j=%d,d=\"|:p=%g,r=%g\"", C->dadlink->joint_refno, C->P.muscle_power, C->mz);
     246                        partidx = addFromString(NeuronType, tmpLine, &range);
    247247                        if (partidx < 0) return -32;
    248                         sprintf(tmpLine, "c:%d,%d", partidx, n_refno);
    249                         if (singleStepBuild(tmpLine, &range) < 0) return -33;
     248                        sprintf(tmpLine, "%d,%d", partidx, n_refno);
     249                        if (addFromString(NeuronConnectionType, tmpLine, &range) < 0) return -33;
    250250                }
    251251
     
    256256
    257257                        tmpLine[0] = 0;
    258                         if (1 == C->links[j]->t) sprintf(tmpLine, "n:p=%d,d=\"*\"", p_refno);
    259                         if (2 == C->links[j]->t) sprintf(tmpLine, "n:j=%d,d=\"G\"", C->dadlink->joint_refno);
    260                         if (3 == C->links[j]->t) sprintf(tmpLine, "n:p=%d,d=\"T\"", p_refno);
    261                         if (4 == C->links[j]->t) sprintf(tmpLine, "n:p=%d,d=\"S\"", p_refno);
     258                        if (1 == C->links[j]->t) sprintf(tmpLine, "p=%d,d=\"*\"", p_refno);
     259                        if (2 == C->links[j]->t) sprintf(tmpLine, "j=%d,d=\"G\"", C->dadlink->joint_refno);
     260                        if (3 == C->links[j]->t) sprintf(tmpLine, "p=%d,d=\"T\"", p_refno);
     261                        if (4 == C->links[j]->t) sprintf(tmpLine, "p=%d,d=\"S\"", p_refno);
    262262                        int from = -1;
    263263                        if (tmpLine[0]) //input from receptor
    264264                        {
    265                                 from = singleStepBuild(tmpLine, &range);
     265                                from = addFromString(NeuronType, tmpLine, &range);
    266266                                if (from < 0) return -34;
    267267                        } /*could be 'else'...*/
     
    270270                        if (from >= 0)
    271271                        {
    272                                 sprintf(tmpLine, "c:%d,%d,%g", n_refno, from, C->links[j]->w);
    273                                 if (singleStepBuild(tmpLine, &range) < 0) return -35;
     272                                sprintf(tmpLine, "%d,%d,%g", n_refno, from, C->links[j]->w);
     273                                if (addFromString(NeuronConnectionType, tmpLine, &range) < 0) return -35;
    274274                        }
    275275                }
Note: See TracChangeset for help on using the changeset viewer.