Exemple #1
0
        private Rabbit NewRabbit(GeneticData data)
        {
            Vector2f position, facing;

            //position = Vector2.Random(rd, Padding, Window.Size.X - Padding, Padding, Window.Size.Y - Padding);
            position = new Vector2f(10, Window.Size.Y / 2);

            facing = Vector2.Random(rd, -1, 1, -1, 1);


            return(new Rabbit(position, facing, data, rd, Entities, (Vector2f)Window.Size, WorldTime));
        }
Exemple #2
0
        private Rabbit NewRabbit()
        {
            float       speed, viewRange, actRange, mutation;
            GeneticData data;

            speed     = DefaultsData.SpeedBase + (float)(rd.NextDouble() - 0.5) * DefaultsData.SpeedVariation;
            viewRange = DefaultsData.ViewRangeBase + (float)(rd.NextDouble() - 0.5) * DefaultsData.ViewRangeVariation;
            actRange  = DefaultsData.ActBase + (float)(rd.NextDouble() - 0.5) * DefaultsData.ActVariation;
            mutation  = DefaultsData.MutationBase + (float)(rd.NextDouble() - 0.5) * DefaultsData.MutationVariation;

            data = new GeneticData(viewRange, actRange, speed, mutation);

            return(NewRabbit(data));
        }
Exemple #3
0
        /// <summary>
        /// Execute the operation on the data.
        /// </summary>
        /// <param name="data"></param>
        public void execute(GeneticData data)
        {
            IList<KeyValuePair<String, IDeepClonable>> updates = new List<KeyValuePair<String, IDeepClonable>>();

            foreach (KeyValuePair<String, IDeepClonable> entry in data)
            {
                // Vérification
                if (targetedGenes.contains(entry.Key) && entry.Value.GetType() == computeType)
                {
                    updates.Add(new KeyValuePair<String, IDeepClonable>(entry.Key, (IDeepClonable)compute(entry.Value)));
                }
            }

            // Applying the updates.
            foreach (KeyValuePair<String, IDeepClonable> entry in updates)
            {
                data.set(entry.Key, entry.Value);
            }
        }
        public void LoadData(List <FileDataModel> files)
        {
            foreach (var f in files)
            {
                Console.WriteLine(f.FileName);
                DataCache.Add(BuildModel(f));
            }

            foreach (var r in DataCache[0])
            {
                GeneticData.Add(r);

                var avgPosX = (r.StartPosition + r.EndPosition) / 2;
            }

            BackingData = GeneticData;

            Console.WriteLine($"Genetic Data: {GeneticData.Count}");
        }
        public Rabbit(Vector2f position, Vector2f facing, GeneticData data, Random rd, List <Entity> entities, Vector2f limits, WorldTime time) : base(position, facing, data, rd, limits, time)
        {
            shape                  = new CircleShape(Data.Genes.ActRange, 3);
            shape.FillColor        = GetColorByData();
            shape.OutlineThickness = Outline;
            shape.OutlineColor     = OutlineColor;
            shape.Origin           = new Vector2f(Size, Size);
            Entities               = entities;

            //rangeShape = new CircleShape(data.ViewRange);
            //rangeShape.OutlineColor = OutlineColor;
            //rangeShape.OutlineThickness = Outline;
            //rangeShape.FillColor = RangeColor;
            //rangeShape.Origin = new Vector2f(data.ViewRange, data.ViewRange);

            Energy = EnergyDefault;

            lbl_Food           = new Text(FoodQuantity.ToString(), DebugSimulationData.Font, 10);
            lbl_Food.FillColor = DebugSimulationData.FontColor;
        }
Exemple #6
0
 public Cylinder(GeneticData data)
     : base(data)
 {
 }
Exemple #7
0
 public Square(GeneticData data)
     : base(data)
 {
 }
Exemple #8
0
 public Tubular(GeneticData data)
     : base(data)
 {
 }
Exemple #9
0
 public Plate(GeneticData data)
     : base(data)
 {
 }
Exemple #10
0
 public Sphere(GeneticData data)
     : base(data)
 {
 }