public void UpdateKillsCellsWithLessThanTwoNeighbors() { Cell[][] boardConfiguration = new [] { new [] { new Cell(GameOfLifeCellState.Alive, new List <Cell>() { new Cell(GameOfLifeCellState.Alive) }) } }; var gameOfLife = CellularAutomatonFactory.CreateGameOfLife(1, 1, CreateMockBoardFactory(1, 1, boardConfiguration)); gameOfLife.Update(); Assert.AreEqual(GameOfLifeCellState.Dead, gameOfLife.Board.Cells[0][0].State); }
public void UpdateResurrectsDeadCellsWithExactlyThreeAliveNeighbors() { Cell[][] boardConfiguration = new[] { new[] { new Cell(GameOfLifeCellState.Dead, new List <Cell>() { new Cell(GameOfLifeCellState.Alive), new Cell(GameOfLifeCellState.Alive), new Cell(GameOfLifeCellState.Alive) }) } }; var gameOfLife = CellularAutomatonFactory.CreateGameOfLife(1, 1, CreateMockBoardFactory(1, 1, boardConfiguration)); gameOfLife.Update(); Assert.AreEqual(GameOfLifeCellState.Alive, gameOfLife.Board.Cells[0][0].State); }
public void Run() { var mainWindow = new MainWindow(); Thread worker = new Thread(() => { var gameOfLife = CellularAutomatonFactory.CreateGameOfLife(100, 100); while (true) { Thread.Sleep(500); var transformedCells = Transform(gameOfLife.Board); Application.Current.Dispatcher.Invoke(() => mainWindow.Draw(transformedCells, gameOfLife.Board.Width, gameOfLife.Board.Height)); gameOfLife.Update(); } }); mainWindow.Closing += (sender, args) => worker.Abort(); mainWindow.Show(); worker.Start(); }