Exemplo n.º 1
0
        private void GameLoop()
        {
            var validMoves           = new List <Move>();
            int whiteRemainingPieces = 0;
            int blackRemainingPieces = 0;

            do
            {
                game.PrintBoard();
                validMoves = game.GetValidMovesRemaining();

                var move = game.GetNextMove();
                game.DoMove(move);

                whiteRemainingPieces = CheckForWinState("White");
                if (whiteRemainingPieces == 0)
                {
                    break;
                }
                blackRemainingPieces = CheckForWinState("Black");
                if (blackRemainingPieces == 0)
                {
                    break;
                }

                validMoves = game.GetValidMovesRemaining();
            } while (validMoves.Count > 0);

            if (blackRemainingPieces > 0 && whiteRemainingPieces > 0)
            {
                Console.WriteLine("No valid moves left. Draw game! Thanks for playing.");
                isDraw = true;
            }
        }