//internal List<Generation> getHistoryBatch(int startGeneration, int endGeneration) //{ // var universe = new Universe(StartSeed); // int generationNumber = 0; // List<Generation> historyBatch = new List<Generation>(); // while (generationNumber <= endGeneration) // { // var cells = HsToList(universe.PopulateNextGen()); // generationNumber += 1; // if (generationNumber >= startGeneration) // { // historyBatch.Add(new Generation() { Cells = cells, GenerationNumber = generationNumber }); // } // } // return historyBatch; //} public HashSet <Tuple <int, int> > PopulateNextGen() { PotentialCells.Clear(); NextGenCells.Clear(); foreach (var cell in CurrentGenCells) { if (Rules.ShouldLive(CheckNeighbours(cell.Item1, cell.Item2))) { NextGenCells.Add(new Tuple <int, int>(cell.Item1, cell.Item2)); } } var results = PotentialCells.Where(p => Rules.ShouldZombiefy(p.Value)).ToHashSet(); foreach (var result in results) { NextGenCells.Add(new Tuple <int, int>(result.Key.Item1, result.Key.Item2)); } GlobalHost.ConnectionManager.GetHubContext <GameHub>().Clients.All.nextUniverseStep(HsToList(CurrentGenCells)); CurrentGenCells = NextGenCells; NextGenCells = new HashSet <Tuple <int, int> >(); return(CurrentGenCells); }
public void Overpopulation(int aliveNeighbours) { var result = Rules.ShouldLive(aliveNeighbours); Assert.IsFalse(result); }
public void Survive(int aliveNeighbours) { var result = Rules.ShouldLive(aliveNeighbours); Assert.IsTrue(result); }