Exemplo n.º 1
0
        public void Initialize(Board board, int xPosition, int yPosition)
        {
            Status = false;
            _board = board;

            _surroundings = PopulateSurroundings(xPosition, yPosition);
            NumberOfNeighbors = GetNumberOfNeighbors();
            IsAlive = _surroundings[1, 1] == 1;
        }
Exemplo n.º 2
0
        static void Main()
        {
            int? size = GetBoardSize();

            if (!size.HasValue)
            {
                Console.WriteLine("Provided value is not an integer.  Exiting.");
                return;
            }

            Board board = new Board(size.Value);

            board.CreateBoard();

            Console.WriteLine("The board entered:");
            board.PrintBoard();

            IGameEngine engine = new GameEngine(board);
            while (true)
            {
                Console.WriteLine("To play a turn, simply press any key other than N.  To quit, press 'N'.");
                string input = Console.ReadLine();

                if (input == "N")
                {
                    break;
                }

                engine.TakeTurn();

                Console.WriteLine("\nBoard result:");
                board.PrintBoard();
            }

            Console.ReadLine();
        }
Exemplo n.º 3
0
 public GameEngine(Board board)
 {
     _board = board;
 }