History #19

Merged
rektdie merged 6 commits from history into legalMovegen 2025-03-15 12:47:47 +01:00
Showing only changes of commit 081cfd5431 - Show all commits
+9 -7
View File
@@ -205,8 +205,10 @@ SearchResults PVS(Board board, int depth, int alpha, int beta) {
// For all moves // For all moves
for (int i = 0; i < board.currentMoveIndex; i++) { for (int i = 0; i < board.currentMoveIndex; i++) {
Move currMove = board.moveList[i];
Board copy = board; Board copy = board;
copy.MakeMove(copy.moveList[i]); copy.MakeMove(currMove);
// First move (suspected PV node) // First move (suspected PV node)
if (!i) { if (!i) {
@@ -230,13 +232,9 @@ SearchResults PVS(Board board, int depth, int alpha, int beta) {
// Fail high (beta cutoff) // Fail high (beta cutoff)
if (score >= beta) { if (score >= beta) {
Move currMove = board.moveList[i];
if (!currMove.IsCapture()) { if (!currMove.IsCapture()) {
killerMoves[1][ply] = killerMoves[0][ply]; killerMoves[1][ply] = killerMoves[0][ply];
killerMoves[0][ply] = currMove; killerMoves[0][ply] = currMove;
historyMoves[board.sideToMove][currMove.MoveFrom()][currMove.MoveTo()] += depth * depth;
} }
TT.WriteEntry(board.hashKey, depth, score, CutNode, Move()); TT.WriteEntry(board.hashKey, depth, score, CutNode, Move());
@@ -246,10 +244,14 @@ SearchResults PVS(Board board, int depth, int alpha, int beta) {
results.score = std::max(score, results.score); results.score = std::max(score, results.score);
if (score > alpha) { if (score > alpha) {
if (!currMove.IsCapture()) {
historyMoves[board.sideToMove][currMove.MoveFrom()][currMove.MoveTo()] += depth * depth;
}
nodeType = PV; nodeType = PV;
alpha = score; alpha = score;
results.bestMove = board.moveList[i]; results.bestMove = currMove;
pvLine.SetMove(ply, board.moveList[i]); pvLine.SetMove(ply, currMove);
} }
} }