当前位置: 首页>>代码示例>>C++>>正文


C++ Genome::HasDeadEnds方法代码示例

本文整理汇总了C++中Genome::HasDeadEnds方法的典型用法代码示例。如果您正苦于以下问题:C++ Genome::HasDeadEnds方法的具体用法?C++ Genome::HasDeadEnds怎么用?C++ Genome::HasDeadEnds使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Genome的用法示例。


在下文中一共展示了Genome::HasDeadEnds方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: MutateGenome


//.........这里部分代码省略.........
        case ADD_LINK:
            t_mutation_success = t_baby.Mutate_AddLink(a_Pop.AccessInnovationDatabase(), a_Parameters, a_RNG);
            break;

        case REMOVE_NODE:
            t_mutation_success = t_baby.Mutate_RemoveSimpleNeuron(a_Pop.AccessInnovationDatabase(), a_RNG);
            break;

        case REMOVE_LINK:
        {
            // Keep doing this mutation until it is sure that the baby will not
            // end up having dead ends or no links
            Genome t_saved_baby = t_baby;
            bool t_no_links = false, t_has_dead_ends = false;

            int t_tries = 128;
            do
            {
                t_tries--;
                if (t_tries <= 0)
                {
                    t_saved_baby = t_baby;
                    break; // give up
                }

                t_saved_baby = t_baby;
                t_mutation_success = t_saved_baby.Mutate_RemoveLink(a_RNG);

                t_no_links = t_has_dead_ends = false;

                if (t_saved_baby.NumLinks() == 0)
                    t_no_links = true;

                t_has_dead_ends = t_saved_baby.HasDeadEnds();

            }
            while(t_no_links || t_has_dead_ends);

            t_baby = t_saved_baby;

            // debugger trap
            if (t_baby.NumLinks() == 0)
            {
                std::cerr << "No links in baby after mutation" << std::endl;
            }
            if (t_baby.HasDeadEnds())
            {
                std::cerr << "Dead ends in baby after mutation" << std::endl;
            }
        }
        break;

        case CHANGE_ACTIVATION_FUNCTION:
            t_baby.Mutate_NeuronActivation_Type(a_Parameters, a_RNG);
            t_mutation_success = true;
            break;

        case MUTATE_WEIGHTS:
            t_baby.Mutate_LinkWeights(a_Parameters, a_RNG);
            t_mutation_success = true;
            break;

        case MUTATE_ACTIVATION_A:
            t_baby.Mutate_NeuronActivations_A(a_Parameters, a_RNG);
            t_mutation_success = true;
            break;
开发者ID:Arpic,项目名称:robogen,代码行数:67,代码来源:Species.cpp


注:本文中的Genome::HasDeadEnds方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。