コード例 #1
0
        public static UInt64 rookAttacks(UInt64 occ, int s)
        {
            UInt64 binaryS = bitMask[s];
            UInt64 possibilitiesHorizontal = (occ - 2 * binaryS) ^ BitOps.ReverseBytes(BitOps.ReverseBytes(occ) - 2 * BitOps.ReverseBytes(binaryS));
            UInt64 possibilitiesVertical   = ((occ & FilesBoard[s % 8]) - (2 * binaryS)) ^ BitOps.ReverseBytes(BitOps.ReverseBytes(occ & FilesBoard[s % 8]) - (2 * BitOps.ReverseBytes(binaryS)));

            return((possibilitiesHorizontal & RanksBoard[s / 8]) | (possibilitiesVertical & FilesBoard[s % 8]));
        }
コード例 #2
0
        public static UInt64 bishopAttacks(UInt64 occ, int s)
        {
            UInt64 binaryS = bitMask[s];
            UInt64 possibilitiesDiagonal     = ((occ & DiagonalBoard[(s / 8) + (s % 8)]) - (2 * binaryS)) ^ BitOps.ReverseBytes(BitOps.ReverseBytes(occ & DiagonalBoard[(s / 8) + (s % 8)]) - (2 * BitOps.ReverseBytes(binaryS)));
            UInt64 possibilitiesAntiDiagonal = ((occ & AntiDiagonalBoard[(s / 8) + 7 - (s % 8)]) - (2 * binaryS)) ^ BitOps.ReverseBytes(BitOps.ReverseBytes(occ & AntiDiagonalBoard[(s / 8) + 7 - (s % 8)]) - (2 * BitOps.ReverseBytes(binaryS)));

            return((possibilitiesDiagonal & DiagonalBoard[(s / 8) + (s % 8)]) | (possibilitiesAntiDiagonal & AntiDiagonalBoard[(s / 8) + 7 - (s % 8)]));
        }