コード例 #1
0
ファイル: FieldSet.cs プロジェクト: aidded/ClassLibary5194
        public static FieldSet NewField(BleepyBloop[] Olds)
        {
            List<Instruction[]> temp = new List<Instruction[]>();
            List<Instruction[]> clones = new List<Instruction[]>();
            List<double> PastFoods = new List<double>();
            List<Instruction> GenePool = new List<Instruction>();
            Olds = Olds.OrderByDescending(y => y.ObjectiveFunction()).ToArray();
            Field F = new Field(Olds.Count());
            double Mean = FillGenePool(Olds, clones, GenePool,PastFoods);
            AddPaddingToGenePool(GenePool);

            FillFromGenePool(temp, GenePool);
            F.Bloops = new BleepyBloop[temp.Count() + clones.Count()];
            AddBloopsToField(temp, clones, F,Mean,PastFoods);
            F = Field.GenerateNewLevel(F.Bloops.ToArray());
            return FieldSetFromField(F);
        }
コード例 #2
0
ファイル: FieldSet.cs プロジェクト: aidded/ClassLibary5194
 private static void AddBloopsToField(List<Instruction[]> temp, List<Instruction[]> clones, Field F,double Mean,List<double> PastFoods)
 {
     for (int i = 0; i < temp.Count(); i++)
     {
         BleepyBloop B = F.Bloops[i];
         B = new BleepyBloop();
         B.Genes = temp[i];
         B.Vary(0.08, 0.08);
         B.parentsFood = Mean;
         F.Bloops[i] = B;
     }
     for (int i = 0; i < clones.Count(); i++)
     {
         int b = i + temp.Count;
         F.Bloops[b] = new BleepyBloop();
         F.Bloops[b].Genes = clones[i];
         F.Bloops[b].parentsFood = PastFoods[i];
     }
 }
コード例 #3
0
ファイル: FieldSet.cs プロジェクト: aidded/ClassLibary5194
 private static Field NewFieldWithRandomBloops(int Number)
 {
     Field F = new Field(Number);
     F.Bloops = new BleepyBloop[Number];
     F.bleepSim.Bloops = F.Bloops;
     F.physicalLevel.Foods = new List<Food>();
     F.physicalLevel.Poisons = new List<Poison>();
     for (int i = 0; i < Number; i++)
     {
         F.Bloops[i] = new BleepyBloop();
     }
     F.physicalLevel.AddNewFoodAndPoison(48);
     F.physicalLevel.UpdateThingChache(F);
     F.bleepSim.SetThreads(BleepSim.NumThread,Field.NF);
     return F;
 }
コード例 #4
0
ファイル: FieldSet.cs プロジェクト: aidded/ClassLibary5194
 private static FieldSet FieldSetFromField(Field F)
 {
     FieldSet S = new FieldSet();
     S.Generations = new List<Field>();
     S.Generations.Add(F);
     return S;
 }
コード例 #5
0
 public void UpdateThingChache(Field F)
 {
     List<IPhysical<Vector2d>> J = new List<IPhysical<Vector2d>>();
     J.AddRange(F.Bloops);
     foreach (Food B in Foods)
     {
         J.Add(B);
     }
     foreach (Poison B in Poisons)
     {
         J.Add(B);
     }
     foreach (Rock R in Rocks)
     {
         J.Add(R);
     }
     ThingsCache = J;
     ThingsCacheXAsc = J.OrderBy(t => t.Position.x).ToArray();
     ThingsCacheYAsc = J.OrderBy(t => t.Position.y).ToArray();
     FrameValid = F.Frame;
 }
コード例 #6
0
 public IPhysical<Vector2d>[] ThingsYAsc(Field F)
 {
     if (F.Frame != FrameValid)
     {
         UpdateThingChache(F);
     }
     return ThingsCacheYAsc;
 }
コード例 #7
0
 public List<IPhysical<Vector2d>> Things(Field F)
 {
     if (F.Frame != FrameValid)
     {
         UpdateThingChache(F);
     }
     return ThingsCache;
 }
コード例 #8
0
ファイル: Fields.cs プロジェクト: aidded/ClassLibary5194
        private static Field InitNewFieldWithOldBleeps(BleepyBloop[] Olds)
        {
            Field F = new Field(Olds.Count());
            F.Bloops = new BleepyBloop[Olds.Count()];
            F.physicalLevel.Foods = new List<Food>();
            F.physicalLevel.Poisons = new List<Poison>();
            for (int i = 0; i < Olds.Count(); i++)
            {
                F.Bloops[i] = new BleepyBloop();
                F.Bloops[i] = new BleepyBloop();
                F.Bloops[i].Genes = Olds[i].Genes;
                F.Bloops[i].Food += Olds[i].Food;
            }

            return F;
        }