Example #1
0
        internal GenePool CreateChild(DNAPool father, DNAPool mother)
        {
            GenePool child = new GenePool();
            EnumBase dominant;
            EnumBase recessive;
            Gene     gc;

            foreach (Gene f in father.GetGenes)
            {
                Type trait = f.Trait;

                Gene m = mother.GetGenes.FindByTrait(trait);

                EnumBase allele1 = GetAllele(f.Dominant, m.Dominant);
                EnumBase allele2 = GetAllele(f.Recessive, m.Recessive);

                if (allele1.Dominancy >= allele2.Dominancy)
                {
                    dominant  = allele2;
                    recessive = allele1;
                }
                else
                {
                    dominant  = allele1;
                    recessive = allele2;
                }

                gc = new Gene(trait, dominant, recessive);
                child.Add(gc);
            }

            return(child);
        }
Example #2
0
        protected DNAPool(int id, DNAPool f, DNAPool m)
        {
            ID = id;
            SetParents(f, m);

            if (GenePool == null)
            {
                GenePool = new GenePool();
            }

            if (!GenePool.Exists)
            {
                GenePool.Init();
            }

            if (GenePool.IsEmpty)
            {
                GenePool = DNAController.GetSingleton().CreateChild(Father, Mother);
            }
        }
Example #3
0
 protected void SetParents(DNAPool f, DNAPool m)
 {
     Father = f;
     Mother = m;
 }