Runs a tick in the game word, apply the Game of Life rule to each cell in the grid
View code on GitHub Namespace: GameOfLifeAssembly: GameOfLife (in GameOfLife.exe) Version: 1.1.1.0 (1.1.1)
public void SimulateNextGeneration()
public void SimulateNextGeneration()
Public Sub SimulateNextGeneration
Public Sub SimulateNextGeneration
public:
void SimulateNextGeneration()
public:
void SimulateNextGeneration()
member SimulateNextGeneration : unit -> unit
member SimulateNextGeneration : unit -> unit
Tests:
GameOfLife.Tests.GameOfLifeTests5 unit tests call GameOfLife.GameOfLife.SimulateNextGeneration
[Test, CloseAfterFirstFrame]
public void RunningSimulationIncrementsGenerationByOne()
{
Assert.AreEqual(0, gameOfLife.Generation);
gameOfLife.SimulateNextGeneration();
Assert.AreEqual(1, gameOfLife.Generation);
}
[Test, CloseAfterFirstFrame]
public void RunningSimulationIncrementsGenerationByOne()
{
Assert.AreEqual(0, gameOfLife.Generation);
gameOfLife.SimulateNextGeneration();
Assert.AreEqual(1, gameOfLife.Generation);
}
[Test, CloseAfterFirstFrame]
public void ResetGameState()
{
ReviveAllCells();
gameOfLife.SimulateNextGeneration();
gameOfLife.ResetGameState();
Assert.AreEqual(0, gameOfLife.Population);
Assert.AreEqual(0, gameOfLife.Generation);
}
[Test, CloseAfterFirstFrame]
public void ResetGameState()
{
ReviveAllCells();
gameOfLife.SimulateNextGeneration();
gameOfLife.ResetGameState();
Assert.AreEqual(0, gameOfLife.Population);
Assert.AreEqual(0, gameOfLife.Generation);
}
[Test, CloseAfterFirstFrame]
public void LiveCellWithMoreThanThreeLiveNeighborsDies()
{
InitializeGameOfLife(new Size(3));
ReviveAllCells();
gameOfLife.SimulateNextGeneration();
Assert.IsFalse(gameOfLife.IsCellAlive(1, 1));
}
[Test, CloseAfterFirstFrame]
public void LiveCellWithMoreThanThreeLiveNeighborsDies()
{
InitializeGameOfLife(new Size(3));
ReviveAllCells();
gameOfLife.SimulateNextGeneration();
Assert.IsFalse(gameOfLife.IsCellAlive(1, 1));
}