private void CalculateNextGeneration() { _universe = GameOfLife.CalculateStep(_universe); _generations++; SaveToHistory(); UpdateCounters(); if (_universe.IsEmpty) { ToggleTimer(); } }
public void GameOfLife_WithExpectedNewborn_Succeeds() { var startUniverse = UniverseFactory.GetFromMatrixString(new[] { " x ", " xx" }); var expectedUniverse = UniverseFactory.GetFromMatrixString(new[] { " xx", " xx" }); var result = GameOfLife.CalculateStep(startUniverse); result.Cells.Should().BeEquivalentTo(expectedUniverse.Cells); }
public void GameOfLife_WithDyingConfiguration_Succeeds() { var lines = new[] { "x x", " x", " x ", " x x ", " x", "x", "x" }; var startUniverse = UniverseFactory.GetFromMatrixString(lines); var result = GameOfLife.CalculateStep(startUniverse); result.IsEmpty.Should().BeTrue(); }
public void GameOfLife_WithStableConfiguration_Succeeds() { var lines = new[] { " xx", " xx", " xx ", " xx xx ", " xx", "xx", "xx" }; var startUniverse = UniverseFactory.GetFromMatrixString(lines); var result = GameOfLife.CalculateStep(startUniverse); result.Cells.Should().BeEquivalentTo(startUniverse.Cells); }