public void GliderMovesBoundsUp() { var initial = new[] { 1, 1, 1, 0, 0, 1, 0, 1, 0, }; var step1 = new[] { 0, 1, 0, 0, 1, 1, 1, 0, 1, 0, 0, 0, }; var universe = new Universe(3, 3); universe.SetUniverse(initial); universe.Tick(); UniverseAssert.Equal(step1, universe); UniverseAssert.BoundsEqual(-1, -2, 3, 4, universe); }
public void BarOscillates() { var step1 = new[] { 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, }; var step2 = new[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }; var universe = new Universe(5, 5); universe.SetUniverse(step1); var changed = universe.Tick(); Assert.True(changed); UniverseAssert.Equal(step2, universe); changed = universe.Tick(); Assert.True(changed); UniverseAssert.Equal(step1, universe); }
public void CellWithFourNeighborsStaysAlive() { var initial = new[] { 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, }; var universe = new Universe(5, 5); universe.SetUniverse(initial); var changed = universe.Tick(); Assert.True(changed); var expected = new[] { 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 1, 0, 1, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, }; UniverseAssert.Equal(expected, universe); }
public void IndexerChangesBounds(int x, int y, int minX, int minY, int width, int height) { var universe = new Universe(3, 3); universe[x, y] = CellState.Alive; UniverseAssert.BoundsEqual(minX, minY, width, height, universe); }
public void GliderMovesBoundsMultipleTimes() { var initial = new[] { 0, 1, 0, 0, 0, 1, 1, 1, 1, }; var step1 = new[] { 0, 0, 0, 1, 0, 1, 0, 1, 1, 0, 1, 0, }; var step2 = new[] { 0, 0, 0, 0, 0, 1, 1, 0, 1, 0, 1, 1, }; var step3 = new[] { 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 1, 0, 1, 1, 0, }; var universe = new Universe(3, 3); universe.SetUniverse(initial); universe.Tick(); UniverseAssert.Equal(step1, universe); UniverseAssert.BoundsEqual(-1, -1, 3, 4, universe); universe.Tick(); UniverseAssert.Equal(step2, universe); UniverseAssert.BoundsEqual(-1, -1, 3, 4, universe); universe.Tick(); UniverseAssert.Equal(step3, universe); UniverseAssert.BoundsEqual(-1, -1, 4, 4, universe); }
public void DiamondPatternStaysTheSame() { var initial = new[] { 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, }; var universe = new Universe(6, 5); universe.SetUniverse(initial); var changed = universe.Tick(); Assert.False(changed); UniverseAssert.Equal(initial, universe); }
public void CellWithOnlyThreeNeighborsStaysAlive() { var initial = new[] { 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }; var universe = new Universe(5, 5); universe.SetUniverse(initial); var changed = universe.Tick(); Assert.False(changed); UniverseAssert.Equal(initial, universe); }