public void Mutate() { var newWorld = World.EmptyClone(); foreach(var x in Range(World.Dimension)) foreach(var y in Range(World.Dimension)) newWorld[x, y] = GetMutatedState(x, y); World = newWorld; }
public void Blinker() { var preCells = new World(new int[,] { { 0, 0, 0 }, { 1, 1, 1 }, { 0, 0, 0 } }); var postCells = new World(new int[,] { { 0, 1, 0 }, { 0, 1, 0 }, { 0, 1, 0 } }); TestMutation(preCells, postCells); }
public void Block() { var preCells = new World(new int[,] { { 0, 0, 0, 0 }, { 0, 1, 1, 0 }, { 0, 1, 1, 0 }, { 0, 0, 0, 0 } }); var afterCells = new World(new int[,] { { 0, 0, 0, 0 }, { 0, 1, 1, 0 }, { 0, 1, 1, 0 }, { 0, 0, 0, 0 } }); TestMutation(preCells, afterCells); }
public bool Equals(World other) { return GetHashCode() == other.GetHashCode(); }
public GameOfLife(World world) { World = world; }
public void ZeroCellsShouldMutateToZeroCells() { var preCells = new World(new int[,] {{}}); var afterCells = new World(new int[,] {{}}); TestMutation(preCells, afterCells); }
void TestMutation(World pre, World post) { var game = new GameOfLife(pre); game.Mutate(); Assert.That(game.World, Is.EqualTo(post)); }