Пример #1
0
        public static LeafList GetAvailableMoves(byte[] board, ChessColor color, bool allowCheck)
        {
            bool     white = color == ChessColor.White;
            LeafList moves = new LeafList();

            //iterate thru entire board {64} including row delimiters {7}
            for (int i = 0; i < OUTOFBOUNDSHIGH; ++i)
            {
                if (!white)
                {
                    switch (board[i])
                    {
                    case 0x02:
                        board.AddPawnMoves(white, i, ref moves, allowCheck);
                        break;

                    case 0x04:
                        board.AddAdjacentMaps(white, i, ref moves, allowCheck);
                        break;

                    case 0x06:
                        board.AddDiagonalMaps(white, i, ref moves, allowCheck);
                        break;

                    case 0x08:
                        board.AddKnightMoves(white, i, ref moves, allowCheck);
                        break;

                    case 0x0A:
                        board.AddAdjacentMaps(white, i, ref moves, allowCheck);
                        board.AddDiagonalMaps(white, i, ref moves, allowCheck);
                        break;

                    case 0x0C:
                        board.AddKingMoves(white, i, ref moves, allowCheck);
                        break;

                    default: break;
                    }
                }
                else
                {
                    switch (board[i])
                    {
                    case 0x01:
                        board.AddPawnMoves(white, i, ref moves, allowCheck);
                        break;

                    case 0x03:
                        board.AddAdjacentMaps(white, i, ref moves, allowCheck);
                        break;

                    case 0x05:
                        board.AddDiagonalMaps(white, i, ref moves, allowCheck);
                        break;

                    case 0x07:
                        board.AddKnightMoves(white, i, ref moves, allowCheck);
                        break;

                    case 0x09:
                        board.AddAdjacentMaps(white, i, ref moves, allowCheck);
                        board.AddDiagonalMaps(white, i, ref moves, allowCheck);
                        break;

                    case 0x0B:
                        board.AddKingMoves(white, i, ref moves, allowCheck);
                        break;

                    default: break;
                    }
                }
            }
            return(moves);
        }
Пример #2
0
        public static LightList GetAvailableMoves(char[] board, ChessColor color, bool allowCheck)
        {
            bool      white = color == ChessColor.White;
            LightList moves = new LightList();

            //iterate thru entire board {64} including row delimiters {7}
            for (int i = 0; i < 71; ++i)
            {
                if (!white)
                {
                    switch (board[i])
                    {
                    case 'p':
                        board.AddPawnMoves(white, i, ref moves, allowCheck);
                        break;

                    case 'r':
                        board.AddAdjacentMaps(white, i, ref moves, allowCheck);
                        break;

                    case 'b':
                        board.AddDiagonalMaps(white, i, ref moves, allowCheck);
                        break;

                    case 'n':
                        board.AddKnightMoves(white, i, ref moves, allowCheck);
                        break;

                    case 'q':
                        board.AddAdjacentMaps(white, i, ref moves, allowCheck);
                        board.AddDiagonalMaps(white, i, ref moves, allowCheck);
                        break;

                    case 'k':
                        board.AddKingMoves(white, i, ref moves, allowCheck);
                        break;

                    default: break;
                    }
                }
                else
                {
                    switch (board[i])
                    {
                    case 'P':
                        board.AddPawnMoves(white, i, ref moves, allowCheck);
                        break;

                    case 'R':
                        board.AddAdjacentMaps(white, i, ref moves, allowCheck);
                        break;

                    case 'B':
                        board.AddDiagonalMaps(white, i, ref moves, allowCheck);
                        break;

                    case 'N':
                        board.AddKnightMoves(white, i, ref moves, allowCheck);
                        break;

                    case 'Q':
                        board.AddAdjacentMaps(white, i, ref moves, allowCheck);
                        board.AddDiagonalMaps(white, i, ref moves, allowCheck);
                        break;

                    case 'K':
                        board.AddKingMoves(white, i, ref moves, allowCheck);
                        break;

                    default: break;
                    }
                }
            }
            return(moves);
        }