Ejemplo n.º 1
0
        public static bool CheckForGameEnd(GameBoard board, out PlayerColor winner)
        {
            int whitePieces = board.GetPieceCountByOccupation(PlayerColor.White);
            int blackPieces = board.GetPieceCountByOccupation(PlayerColor.Black);

            if (whitePieces == 0)
            {
                winner = PlayerColor.Black;
                return true;
            }
            else if (blackPieces == 0)
            {
                winner = PlayerColor.White;
                return true;
            }
            else if (board.IdleMoves >= MAX_IDLE_MOVES)
            {
                if (whitePieces == blackPieces)
                {
                    winner = PlayerColor.None;
                    return true;
                }

                winner = whitePieces > blackPieces ? PlayerColor.White : PlayerColor.Black;
                return true;
            }

            winner = PlayerColor.None;
            return false;
        }