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)); }
public void World_put1x2_no_advance_return1x2() { World world = new World(new Dimension(3,3)); LiveCell[] cells = new LiveCell[1] { new LiveCell(1, 2) }; world.SetLiveCells(cells); cells = world.GetLiveCells(); Assert.AreEqual(1, cells.Length); Assert.AreEqual(cells[0].X, 1); Assert.AreEqual(cells[0].Y, 2); }
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)); }
public Game(IGameConfig config, GameDisplay display) { if (display == null) { State = GameStateWrongDisplay; return; } _display = display; if (config == null || !config.IsGoodConfig()) { State = GameStateWrongConfig; return; } _world = new World(config.GetDimension()); _world.SetLiveCells(config.GetLiveCells()); _display.SetWorld(_world); }