Exemple #1
0
 private void SetInfos(BugDNA dna, BugData data)
 {
     mInfos.Health.text         = Math.Round(data.Health, 2).ToString();
     mInfos.HealthLossPerS.text = Math.Round(data.HealthLoss, 2).ToString();
     mInfos.ChildCap.text       = Math.Round(data.ChildHealth, 2).ToString();
     mInfos.HealthPerFood.text  = Math.Round(data.FoodHealth, 2).ToString();
     mInfos.MutatioRate.text    = Math.Round(dna[BugValue.MutationRate], 2).ToString();
     mInfos.Parts.text          = data.Parts.ToString();
     mInfos.SightDistance.text  = Math.Round(dna[BugValue.SightDistance], 2).ToString();
     mInfos.Speed.text          = Math.Round(dna[BugValue.Speed], 2).ToString();
     mInfos.TurnMomentum.text   = Math.Round(dna[BugValue.TurnMomentum], 2).ToString();
 }
Exemple #2
0
        public BugDNA Crossover(BugDNA other)
        {
            mRandom = GeneratorController.Random;

            BugDNA that = pGetBugDNA();
            BugDNA dna  = new BugDNA(Crossover(other.Stucture, that.Stucture), Crossover(other.Weights, that.Weights), Crossover(other.Bases, that.Bases));

            foreach (BugValue item in Enum.GetValues(typeof(BugValue)))
            {
                dna[item] = mRandom.NextBool() ? that[item] : other[item];
            }

            return(dna);
        }
        public void Load(BugDNA dna)
        {
            GenerateBug(dna.Stucture);
            mBugStructur = dna.Stucture;

            MutationRate = dna[BugValue.MutationRate];
            Speed = dna[BugValue.Speed];
            TurnMomentum = dna[BugValue.TurnMomentum];
            FoodHealth = dna[BugValue.FoodHealth];
            SightDistance = dna[BugValue.SightDistance];

            pBrain = new Brain(false);
            pBrain.SetNeuronValues(dna.Weights, dna.Bases);

            CalculateValues();
        }
 private void MakeChildTogether(float posX, float posZ, BugDNA dna1, BugDNA dna2) // Subscribed Function
 {
     throw new NotImplementedException();
 }
 public BugDNA GetBugDNA()
 {
     BugDNA dna = new BugDNA(GetBugStructur(), pBrain.Weights, pBrain.Bases);
     dna.SetValues(MutationRate, Speed, TurnMomentum, FoodHealth, SightDistance);
     return dna;
 }