예제 #1
0
    public Monster Breed(Monster other)
    {
        float rand = Random.Range(0.0f, 1.0f);

        if (rand <= SEXUAL_REPRO_CHANCE)
        {
            Dictionary <MonsterTreeNode, int> parent1Map;
            Dictionary <MonsterTreeNode, int> parent2Map;
            MonsterTree    childTree    = this.tree.Breed(other.tree, out parent1Map, out parent2Map);
            InstructionSet remappedSet1 = RemapInstructionSet(this, childTree, parent1Map);
            InstructionSet remappedSet2 = RemapInstructionSet(other, childTree, parent2Map);
            InstructionSet childSet     = remappedSet1.Breed(remappedSet2);
            return(new Monster(childTree, childSet));
        }
        else
        {
            return(Asexual());
        }
    }