public static void RunV1(ILifePattern pattern, int displayOffset) { Console.Clear(); int runs = 0; var sim = new Core.V1.GameSimulation(); sim.SetPattern(pattern); var sw = new Stopwatch(); sw.Start(); while (runs++ < (pattern.MaxGeneration ?? (long.MaxValue - 1))) { GenerationDraw.DrawGame(pattern.Height, pattern.Width, sim.CurrentGeneration); // Give the user a chance to view the game in a more reasonable speed. if (displayOffset > 0) { System.Threading.Thread.Sleep(displayOffset); } sim.SimulateGeneration(); } sw.Stop(); Console.WriteLine(sw.ElapsedMilliseconds); }
public void SetPattern(ILifePattern pattern) { Height = pattern.Height; Width = pattern.Width; MaxGeneration = pattern.MaxGeneration ?? long.MaxValue; CurrentGeneration = pattern.StartingLife; }
public void SetPattern(ILifePattern pattern) { Height = pattern.Height; Width = pattern.Width; MaxGeneration = pattern.MaxGeneration ?? long.MaxValue; CurrentGeneration = new HashSet <Cell>(); CurrentGeneration.UnionWith(pattern.StartingLife.Distinct()); }