コード例 #1
0
ファイル: Genom.cs プロジェクト: Patr0la/Eco
        public static Genom Cross(Genom a, Genom b)
        {
            Trait[] newTraits = new Trait[7];

            for (int i = 0; i < 7; i++)
            {
                Trait traitA      = a.Traits[i];
                Trait traitB      = b.Traits[i];
                int[] activations = new int[traitA.ActiveGenes.Length];

                for (int j = 0; j < traitA.ActiveGenes.Length; j++)
                {
                    if (Simulation.Random.NextDouble() > 0.5)
                    {
                        activations[j] = traitA.ActiveGenes[j];
                    }
                    else
                    {
                        activations[j] = traitB.ActiveGenes[j];
                    }
                }

                newTraits[i] = new Trait(traitA.BaseValue, traitA.BaseValue, activations);
            }

            return(new Genom(newTraits));
        }
コード例 #2
0
ファイル: Animal.cs プロジェクト: Patr0la/Eco
        public Animal(Genom genom, Model model, int x, int y) : base(model, x, y)
        {
            Genom = genom;

            this.x = x;
            this.y = y;

            this.Vision  = Genom.Traits[(int)Traits.Vision].GetValue();
            this.Stamina = Genom.Traits[(int)Traits.Fitness].GetValue();
        }
コード例 #3
0
ファイル: Animal.cs プロジェクト: Patr0la/Eco
 public Animal(int hp, int maxHp, float food, float water, float reproductionUrge, float vision, float stamina, float maxFood, float maxWater, float maxReproductionUrge, float maxStamina, Genom genom, Model model, int x, int y) : base(model, x, y)
 {
     Hp                  = hp;
     MaxHp               = maxHp;
     Food                = food;
     Water               = water;
     ReproductionUrge    = reproductionUrge;
     Vision              = vision;
     Stamina             = stamina;
     MaxFood             = maxFood;
     MaxWater            = maxWater;
     MaxReproductionUrge = maxReproductionUrge;
     MaxStamina          = maxStamina;
 }