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); }
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]; } }
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; }
private static FieldSet FieldSetFromField(Field F) { FieldSet S = new FieldSet(); S.Generations = new List<Field>(); S.Generations.Add(F); return S; }
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; }
public IPhysical<Vector2d>[] ThingsYAsc(Field F) { if (F.Frame != FrameValid) { UpdateThingChache(F); } return ThingsCacheYAsc; }
public List<IPhysical<Vector2d>> Things(Field F) { if (F.Frame != FrameValid) { UpdateThingChache(F); } return ThingsCache; }
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; }