public static CellularAutomaton CreateGameOfLife(int width, int height)
        {
            var neighborshipInitializer = new BoundedNeighborshipInitializer();
            var randomBoardFactory      = new RandomGameOfLifeBoardFactory();

            return(CreateGameOfLife(width, height, randomBoardFactory, neighborshipInitializer));
        }
        public void InitializeSetsRightTopCellAsNeighbor()
        {
            Cell cellToTest       = new Cell(GameOfLifeCellState.Dead);
            Cell rightTopNeighbor = new Cell(GameOfLifeCellState.Alive);
            var  board            = new Board(2, 2, new[] { new[] { new Cell(GameOfLifeCellState.Dead), rightTopNeighbor }, new[] { cellToTest, new Cell(GameOfLifeCellState.Alive), } });
            var  initializer      = new BoundedNeighborshipInitializer();

            initializer.Initialize(board);

            Assert.IsTrue(cellToTest.Neighbors.Contains(rightTopNeighbor));
        }
        public void InitializeSetsLeftBottomCellAsNeighbor()
        {
            Cell cellToTest         = new Cell(GameOfLifeCellState.Dead);
            Cell leftBottomNeighbor = new Cell(GameOfLifeCellState.Alive);
            var  board       = new Board(2, 2, new[] { new[] { new Cell(GameOfLifeCellState.Dead), cellToTest, }, new[] { leftBottomNeighbor, new Cell(GameOfLifeCellState.Alive), } });
            var  initializer = new BoundedNeighborshipInitializer();

            initializer.Initialize(board);

            Assert.IsTrue(cellToTest.Neighbors.Contains(leftBottomNeighbor));
        }
        public void InitializeSetsLeftCellAsNeighbor()
        {
            Cell cellToTest   = new Cell(GameOfLifeCellState.Dead);
            Cell leftNeighbor = new Cell(GameOfLifeCellState.Alive);
            var  board        = new Board(1, 2, new[] { new[] { leftNeighbor, cellToTest } });
            var  initializer  = new BoundedNeighborshipInitializer();

            initializer.Initialize(board);

            Assert.AreEqual(1, cellToTest.Neighbors.Count);
            Assert.AreSame(leftNeighbor, cellToTest.Neighbors[0]);
        }
        public static CellularAutomaton CreateGameOfLife(int width, int height, BoardFactory boardFactory)
        {
            var neighborshipInitializer = new BoundedNeighborshipInitializer();

            return(CreateGameOfLife(width, height, boardFactory, neighborshipInitializer));
        }