public int EvaluateSlidingPiece(Position position, int color, int pieceType, int materialValue, int mobilityMultiplier, ref Bitboard destinationBitboard) { Bitboard pieces = position.GetPieceBitboard(color, pieceType); int score = 0; while (pieces != 0) { score += materialValue; int square = pieces.BitScanForward(); Bitboards.PopLsb(ref pieces); Bitboard attacks = 0; if (pieceType == Position.ROOK || pieceType == Position.QUEEN) { attacks = Bitboards.GetRookMoveBitboard(square, position.AllPiecesBitboard); } if (pieceType == Position.BISHOP || pieceType == Position.QUEEN) { attacks |= Bitboards.GetBishopMoveBitboard(square, position.AllPiecesBitboard); } attacks &= destinationBitboard; score += Bitboards.CountBits(attacks) * mobilityMultiplier; } return(score); }
public void CalculatesCorrectly() { Bitboard occupancyBitboard = 0x780B2201E661F5UL; int square = Position.D3; Assert.AreEqual(0x824428002804UL, Bitboards.GetBishopMoveBitboard(square, occupancyBitboard)); occupancyBitboard = 0x2103A24FEA64C6D8UL; square = Position.A1; Assert.AreEqual(0x4000UL, Bitboards.GetBishopMoveBitboard(square, occupancyBitboard)); occupancyBitboard = 0x356A829C31CABB6AUL; square = Position.D5; Assert.AreEqual(0x244280028040200UL, Bitboards.GetBishopMoveBitboard(square, occupancyBitboard)); }