Merge pull request #5 from rektdie/killer_moves

+killer heuristics
This commit was merged in pull request #5.
This commit is contained in:
rektdie authored and GitHub committed 2025-03-03 17:36:00 +01:00
commit b4c1f7f0f8
1 file changed
+14
+14
View File
@@ -13,6 +13,8 @@ static inline auto timeStart = std::chrono::high_resolution_clock::now();
static inline int timeToSearch = 0;
static inline bool searchStopped = false;
// [id][ply]
static inline int killerMoves[2][64];
static int ScoreMove(Board &board, Move &move) {
const int attackerType = board.GetPieceType(move.MoveFrom());
@@ -25,6 +27,14 @@ static int ScoreMove(Board &board, Move &move) {
if (move.IsCapture()) {
return moveScoreTable[attackerType][targetType] + 10000;
} else {
if (killerMoves[0][ply] == move) {
return 9000;
}
if (killerMoves[1][ply] == move) {
return 8000;
}
}
return 0;
@@ -188,7 +198,11 @@ SearchResults PVS(Board board, int depth, int alpha, int beta) {
}
}
// Fail high (beta cutoff)
if (score >= beta) {
killerMoves[1][ply] = killerMoves[0][ply];
killerMoves[0][ply] = board.moveList[i];
WriteEntry(board.hashKey, depth, beta, CutNode, Move());
return beta;
}