Ignore:
Timestamp:
08/18/17 15:24:59 (8 years ago)
Author:
Maciej Komosinski
Message:

Unified property names of f1 and f4; improved docs; 3.141 -> M_PI

File:
1 edited

Legend:

Unmodified
Added
Removed
  • cpp/frams/genetics/f4/oper_f4.cpp

    r513 r671  
    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-2017  Maciej Komosinski and Szymon Ulatowski.
    33// See LICENSE.txt for details.
    44
     
    231231                // must pick a node with parent, and at least one child
    232232                // already picked a node, but repeat may be needed
    233                 for (int i = 0; i < 10; i++) {
     233                for (int i = 0; i < 10; i++)
     234                {
    234235                        if ((NULL != n1->parent) && (g != n1->parent))
    235236                                if (NULL != n1->child)
     
    247248                                n2 = n1->parent;
    248249                                n2->removeChild(n1);
    249                                 if (NULL != n1->child) {
     250                                if (NULL != n1->child)
     251                                {
    250252                                        n1->child->parent = n2;
    251253                                        n2->addChild(n1->child);
    252254                                        n1->child = NULL;
    253255                                }
    254                                 if (NULL != n1->child2) {
     256                                if (NULL != n1->child2)
     257                                {
    255258                                        n1->child2->parent = n2;
    256259                                        n2->addChild(n1->child2);
     
    309312                        if (i >= 20) return GENOPER_OPFAIL;
    310313                }
    311                 switch (n1->name) {
     314                switch (n1->name)
     315                {
    312316                case '<':
    313317                        // swap children
     
    348352        nn->i1 = i;
    349353        nn->l1 = 0;
    350         if (0 == i) {
     354        if (0 == i)
     355        {
    351356                // relative input link
    352357                nn->l1 = (int)(4.0f * (rnd01 - 0.5f));
     
    407412        if (prob1 < 0.5f) count++;
    408413        else count--;
    409         if (count<1) count = 1;
    410         if (count>REP_MAXCOUNT) count = REP_MAXCOUNT;
     414        if (count < 1) count = 1;
     415        if (count > REP_MAXCOUNT) count = REP_MAXCOUNT;
    411416        nn->i1 = count;
    412417}
     
    464469        if (f4_processrec(g, 0, root) || root->childCount() != 1)
    465470        {
    466                 delete root; return GENOPER_OPFAIL;
     471                delete root;
     472                return GENOPER_OPFAIL;
    467473        } // could not convert or bad: fail
    468474        // mutate one node, set chg as this percent
     
    470476        if (MutateOneValid(root, method) != GENOPER_OK)
    471477        {
    472                 delete root; return GENOPER_OPFAIL;
     478                delete root;
     479                return GENOPER_OPFAIL;
    473480        }
    474481        // OK, convert back to string
Note: See TracChangeset for help on using the changeset viewer.