public void World_no_neighbor_around_1x1_then_dead() { World world = new World(new Dimension(3, 3)); LiveCell[] cells = new LiveCell[1] { new LiveCell(1, 1) }; world.SetLiveCells(cells); world.Advance(); cells = world.GetLiveCells(); Assert.AreEqual(0,cells.Length); }
public void World_3_neighbors_around_dead_0x0_then_live() { World world = new World(new Dimension(3, 3)); LiveCell[] cells = new LiveCell[3] { new LiveCell(0, 1), new LiveCell(1, 0), new LiveCell(1, 1) }; world.SetLiveCells(cells); world.Advance(); Assert.AreEqual(true, HasCell(world, 0, 0)); }
static void Main(string[] args) { ParseArgs(); World world = new World(seed, worldSize); while (!world.Stable) { Console.Clear(); Console.WriteLine(world); world.Advance(); Thread.Sleep(500); } Console.Write("World is stable."); }
public void World_put_two_neightbors_around_1x1_then_alive() { World world = new World(new Dimension(3, 3)); LiveCell[] cells = new LiveCell[3] { new LiveCell(0, 0), new LiveCell(0, 2), new LiveCell(1, 1)}; world.SetLiveCells(cells); //Assert.AreEqual(2, world.GetLiveNeighbors(new LiveCell(1, 1))); world.Advance(); Assert.AreEqual(true, HasCell(world, 1, 1)); }
public void World_put_four_neightbors_around_1x1_then_dead() { World world = new World(new Dimension(3, 3)); LiveCell[] cells = new LiveCell[5] { new LiveCell(0, 0), new LiveCell(0, 2), new LiveCell(1, 1), new LiveCell(2, 0), new LiveCell(0, 1)}; world.SetLiveCells(cells); //Assert.AreEqual(4, world.GetLiveNeighbors(new LiveCell(1, 1))); world.Advance(); Assert.AreEqual(false, HasCell(world, 1, 1)); }