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

-1
View File
@@ -63,7 +63,6 @@ constexpr std::array<std::string_view, 50> fenPositions = {
void RunBenchmark() {
Board board;
int depth = BENCH_DEPTH;
auto ctx = std::make_unique<SearchContext>();
-3
View File
@@ -263,9 +263,6 @@ void PrintProgress(int positions, int targetPositions, Stopwatch &stopwatch, int
lastElapsed = elapsed;
}
int positionsInThousands = static_cast<int>(round(positions / 1000.0));
int targetInThousands = static_cast<int>(round(targetPositions / 1000.0));
std::cout << "\033[H";
int width = 60;
-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;
-5
View File
@@ -170,14 +170,9 @@ static int32_t VectorizedSCReLU(const Board& board, const Network& net, size_t o
}
int Forward(const Board& board, const Network& net) {
bool stm = board.sideToMove;
const size_t divisor = 32 / OUTPUT_BUCKETS;
const size_t outputBucket = (board.occupied.PopCount() - 2) / divisor;
const ACC::Accumulator& stmACC = stm ? board.accPair.white : board.accPair.black;
const ACC::Accumulator& nstmACC = !stm ? board.accPair.white : board.accPair.black;
int64_t eval = 0;
eval = VectorizedSCReLU(board, net, outputBucket);
+1 -1
View File
@@ -36,7 +36,7 @@ static int ScoreMove(Board &board, Move &move, int ply, SearchContext* ctx) {
targetType = Pawn;
}
return 50000 * ((SEE(board, move, -100))) + moveScoreTable[attackerType][targetType];
return 50000 * ((SEE(board, move, -100))) + (100 * targetType - attackerType + 105);
} else {
if (ctx->killerMoves[0][ply] == move) {
return 41000;
-9
View File
@@ -163,15 +163,6 @@ SearchResults SearchPosition(Board &board, SearchParams params, SearchContext* c
bool IsDraw(Board &board, SearchContext* ctx);
constexpr int moveScoreTable[6][6] = {
105, 205, 305, 405, 505, 605,
104, 204, 304, 404, 504, 604,
103, 203, 303, 403, 503, 603,
102, 202, 302, 402, 502, 602,
101, 201, 301, 401, 501, 601,
100, 200, 300, 400, 500, 600
};
void ListScores(Board &board, SearchContext* ctx);
int MoveEstimatedValue(Board& board, Move& move);
+1 -1
View File
@@ -43,7 +43,7 @@ constexpr U64 maxHash = (1024 * 1000000) / sizeof(TTEntry);
// 8 MB
constexpr U64 defaultHash = (8 * 1000000) / sizeof(TTEntry);
constexpr int16_t invalidEntry = 111111;
constexpr int16_t invalidEntry = 11111;
class TTable {
private:
+1 -1
View File
@@ -32,7 +32,7 @@ static void ParsePosition(Board &board, std::string_view command, SEARCH::Search
std::vector<std::string> moves = UTILS::split(command.substr(movesIndex + 6, command.length() - (movesIndex + 5)), ' ');
for (std::string_view move : moves) {
bool isLegal = board.MakeMove(UTILS::parseMove(board, move));
board.MakeMove(UTILS::parseMove(board, move));
ctx->positionHistory[board.positionIndex] = board.hashKey;
}
}