removed unused functions & variables | bench 24146828

This commit is contained in:
rektdie committed 2025-08-05 01:13:57 +02:00
1 parent f0280a77ff
commit cdfb752bfa
9 files changed
+4 -136

No files matched your search

-114
View File
@@ -299,120 +299,6 @@ Bitboard getPawnPushes(int square, bool color, Bitboard &occupancy) {
return pushes;
}
// Returns the direction to target from square
static int GetDirection(int square, int target) {
int rankDiff = (target / 8) - (square / 8);
int fileDiff = (target % 8) - (square % 8);
// Main directions
if (rankDiff == 0 && fileDiff < 0) {
return west;
} else if (rankDiff == 0 && fileDiff > 0) {
return east;
} else if (rankDiff < 0 && fileDiff == 0) {
return south;
} else if (rankDiff > 0 && fileDiff == 0) {
return north;
}
// Diagonals
if (abs(rankDiff) == abs(fileDiff)) {
if (rankDiff < 0 && fileDiff < 0) {
return soWe;
} else if (rankDiff < 0 && fileDiff > 0) {
return soEa;
} else if (rankDiff > 0 && fileDiff < 0) {
return noWe;
} else if (rankDiff > 0 && fileDiff > 0) {
return noEa;
}
}
return 0;
}
// Returns a bitboard of the squares from attacker to target
static Bitboard SliderRayToSquare(int attacker, int target) {
Bitboard ray;
int direction = GetDirection(attacker, target);
if (direction) {
while (attacker != target) {
ray.SetBit(attacker);
attacker += direction;
}
ray.SetBit(target);
}
return ray;
}
static Bitboard GetPinningRay(Board &board, int square, int direction) {
Bitboard ray;
int currentSquare = (board.pieces[King] & board.colors[board.sideToMove]).getLS1BIndex();
int previousRank = currentSquare / 8;
currentSquare += direction;
while (currentSquare < 64 && currentSquare >= 0) {
int currentRank = currentSquare / 8;
int difference = abs(currentRank - previousRank);
if ((abs(direction) == 7 || abs(direction) == 9)
&& difference != 1) {
break;
} else if (abs(direction) == 1 && difference) {
break;
}
previousRank = currentRank;
ray.SetBit(currentSquare);
if (board.occupied.IsSet(currentSquare)) {
if (currentSquare == square) {
currentSquare += direction;
continue;
}
int attackerType = board.GetPieceType(currentSquare);
int attackerColor = board.GetPieceColor(currentSquare);
if (attackerColor != board.sideToMove) {
// Pinned by rook or queen
if (abs(direction) == 1 || abs(direction) == 8) {
if (attackerType == Rook || attackerType == Queen) {
return ray;
}
// Pinned by bishop or queen
} else if (direction % 2 != 0) {
if (attackerType == Bishop || attackerType == Queen) {
return ray;
}
}
}
break;
}
currentSquare += direction;
}
return 0ULL;
}
static bool IsPinned(Board &board, int square) {
int kingSquare = (board.colors[board.sideToMove] & board.pieces[King]).getLS1BIndex();
int directionToKing = GetDirection(square, kingSquare);
if (directionToKing) {
// Checking if there are any pieces between square and kingSquare
if ((SliderRayToSquare(square, kingSquare)
& board.occupied).PopCount() != 2) {
return false;
}
return GetPinningRay(board, square, -directionToKing).PopCount();
}
return false;
}
void GenThreatMaps(Board &board) {
for (int color = White; color <= Black; color++) {
board.colorThreats[color] = 0ULL;