private static ChessBoard PerformWhiteNonAmbiguousMove(ChessBoard board, string notation, ChessBoard tempboard)
        {
            char  goalfile = notation[1];
            sbyte goalrank = (sbyte)Char.GetNumericValue(notation[2]);

            //Check if piece is not-ambigious and get piece square
            List <Square> PossibleMovers = BlackPiece.GetPossibleWhiteAttackersToSquare(board, new Square(goalfile, goalrank));

            Console.WriteLine(PossibleMovers.Count);
            int    NumberOfSamePieces = 0;
            Square PieceSquare        = new Square();

            foreach (Square tempsquare in PossibleMovers)
            {
                if (board[tempsquare] == GetSbyteFromWhitePieceLetter(notation[0]))
                {
                    NumberOfSamePieces++;
                    PieceSquare = tempsquare;
                }
            }
            if (NumberOfSamePieces != 1)
            {
                // Console.WriteLine(NumberOfSamePieces);
                throw new ArgumentException("wrong notation");
            }
            tempboard[PieceSquare.file, PieceSquare.rank] = 0;
            tempboard[goalfile, goalrank] = GetSbyteFromWhitePieceLetter(notation[0]);
            GetPiecePositionsType piecefunction = GetWhitePiecePositionsType(notation[0]);

            //Console.WriteLine(notation[0]);

            if (piecefunction(board, PieceSquare.file, PieceSquare.rank).Contains(tempboard))
            {
                if (board[PieceSquare.file, PieceSquare.rank] == (sbyte)DefaultPieces.WhiteRook && (DefaultInfo.WhiteAsideRookIsUnMoved || DefaultInfo.WhiteHsideRookIsUnMoved))
                {
                    if (DefaultInfo.WhiteAsideRookIsUnMoved && !DefaultInfo.WhiteHsideRookIsUnMoved)
                    {
                        DefaultInfo.WhiteAsideRookIsUnMoved = false;
                    }
                    else if (!DefaultInfo.WhiteAsideRookIsUnMoved && DefaultInfo.WhiteHsideRookIsUnMoved)
                    {
                        DefaultInfo.WhiteHsideRookIsUnMoved = false;
                    }
                    else
                    {
                        char rookfile;
                        for (rookfile = 'a'; rookfile <= 'h'; rookfile++)
                        {
                            if (board[rookfile, 1] == (sbyte)DefaultPieces.WhiteRook)
                            {
                                break;
                            }
                        }
                        if (rookfile < PieceSquare.file)
                        {
                            DefaultInfo.WhiteHsideRookIsUnMoved = false;
                        }
                        else
                        {
                            DefaultInfo.WhiteAsideRookIsUnMoved = false;
                        }
                    }
                }
                return(tempboard);
            }
            else
            {
                throw new ArgumentException("wrong move");
            }
        }
Exemplo n.º 2
0
        public static List <ChessBoard> GetPossiblePositions(ChessBoard board, char file, sbyte rank)
        {
            sbyte piece = (sbyte)DefaultPieces.WhiteQueen;

            return(BlackPiece.GetReversedPossibleWhitePositions(board, file, rank, piece));
        }