private void PutCubi(MapTile t) { Cubi myHeldCubi = Harem.GetId(heldCubiId); myHeldCubi.loc = t.loc; myHeldCubi.beingCarried = false; heldCubiId = 0; Refs.mf.Announce("You're free to go... if you can.", myAlign, myColor); }
private void SwapCubi(MapTile t) { Cubi myHeldCubi = Harem.GetId(heldCubiId); Cubi caughtCubi = Refs.m.CubiAt(t.loc); myHeldCubi.loc = t.loc; myHeldCubi.beingCarried = false; heldCubiId = 0; caughtCubi.loc = this.loc; caughtCubi.beingCarried = true; heldCubiId = caughtCubi.myIdNo; Refs.mf.Announce("Hang on, let's grab you instead!", myAlign, myColor); }
private static Color GetColorMix(MapTile mt) { // speculative -- not sure if I like nectar mixing Int32 mergeR = Refs.p.myColor.R; Int32 mergeG = Refs.p.myColor.G; Int32 mergeB = Refs.p.myColor.B; for (int nLoop = 1; nLoop < mt.nectarLevel.Length - 1; nLoop++) // skip player nectar { mergeR += Harem.GetId(nLoop).myColor.R; mergeG += Harem.GetId(nLoop).myColor.G; mergeB += Harem.GetId(nLoop).myColor.B; } double factor = 1 + Refs.h.roster.Count; mergeR = (Int32)(mergeR / factor); mergeG = (Int32)(mergeG / factor); mergeB = (Int32)(mergeB / factor); return(Color.FromArgb(0, mergeR, mergeG, mergeB)); }
Population Step(Population generation) { //Extensions.WriteColorLine(ConsoleColor.Green, "======={0} Step======", step++); //Console.WriteLine(generation.ToString(fitness)); //Console.WriteLine("Population fitness sum: {0}", // generation.GetPopulationFitnessSum(fitness)); var np = new Population { Individuals = new Roulette(fitness, generation).SpinTheWheel(populationSize) }; //Console.WriteLine(Roulette.ProbabilityToString(generation, fitness)); //Console.WriteLine("Selected for reproducing"); //Console.WriteLine(np.ToString(fitness)); var h = new Harem(fitness, np); var newGeneration = h.Reproduce(); //Console.WriteLine("After reproduction"); //Console.WriteLine(newGeneration.ToString()); //Console.WriteLine("After mutation"); new Mutator(MachinesCount).Mutate(ref newGeneration); //Console.WriteLine(newGeneration.ToString()); #if STORE_BEST_SO_FAR var sorted = newGeneration.Individuals.OrderBy(ComputeSchedulingTime); var currentBest = sorted.First(); if (ComputeSchedulingTime(currentBest) < ComputeSchedulingTime(bestSoFar)) { bestSoFar = currentBest; } #endif #if LOG_PLOT file.WriteLine("{2} {0} {1}", newGeneration.Individuals.Average(x => ComputeSchedulingTime(x)), newGeneration.Individuals.Min(x => ComputeSchedulingTime(x)), step); file.Flush(); #endif return newGeneration; }