示例#1
0
        public static bool IsLegalMove(this BitBoard board, byte player, ulong bitMove)
        {
            if (board.GetPieceAt(bitMove) != Constant.EmptyCell)
            {
                return(false);
            }
            var legalMoves = board.GetLegalMoves(player);

            return((bitMove & legalMoves) != 0);
        }
示例#2
0
        public static void DisplayWithLastMoveAndLegalMoves(this BitBoard board, ulong lastBitMove, byte player)
        {
            Console.WriteLine("  a b c d e f g h");

            var legalMoves = board.GetLegalMoves(player);
            var moveIndex  = lastBitMove.BitScanReverse();
            var row        = 0;

            for (var i = 0; i < 64; i++)
            {
                if (i % 8 == 0)
                {
                    row++;
                    if (i != 0)
                    {
                        Console.WriteLine();
                    }
                    Console.Write(row + " ");
                }

                var pos     = 1UL << i;
                var isBlack = (board.Pieces[Black] & pos) != 0;
                var isWhite = (board.Pieces[White] & pos) != 0;

                if (isBlack && isWhite)
                {
                    Console.Write(Constant.WrongCellStr);
                }
                else if (isBlack)
                {
                    Console.Write(moveIndex == i ? Constant.LastBlackMoveStr : Constant.BlackPieceStr);
                }
                else if (isWhite)
                {
                    Console.Write(moveIndex == i ? Constant.LastWhiteMoveStr : Constant.WhitePieceStr);
                }
                else if ((legalMoves & pos) != 0)
                {
                    Console.Write(Constant.LegalMoveStr);
                }
                else
                {
                    Console.Write(Constant.EmptyCellStr);
                }
            }

            Console.WriteLine();
        }
示例#3
0
 public State(BitBoard board, byte player)
 {
     Player        = player;
     Board         = board;
     BitLegalMoves = board.GetLegalMoves(player);
 }
示例#4
0
 public static bool HasLegalMoves(this BitBoard board, byte player)
 {
     return(board.GetLegalMoves(player) != 0);
 }