From fafa122123c988a43a40cfe976987d727257db71 Mon Sep 17 00:00:00 2001 From: rektdie Date: Fri, 14 Mar 2025 15:48:58 +0100 Subject: [PATCH 1/5] added history moves | bench 1146300 --- source/search.cpp | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/source/search.cpp b/source/search.cpp index d9dd5cd..ff22046 100644 --- a/source/search.cpp +++ b/source/search.cpp @@ -14,6 +14,8 @@ static inline bool doingNullMove = false; // [id][ply] static inline int killerMoves[2][64]; +// [stm][from][to] +static inline int historyMoves[2][64][64]; inline PVLine pvLine; @@ -37,10 +39,10 @@ static int ScoreMove(Board &board, Move &move) { } else { if (killerMoves[0][ply] == move) { return 9000; - } - - if (killerMoves[1][ply] == move) { + } else if (killerMoves[1][ply] == move) { return 8000; + } else { + return historyMoves[board.sideToMove][move.MoveFrom()][move.MoveTo()]; } } @@ -228,8 +230,14 @@ 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]; + Move currMove = board.moveList[i]; + + if (!currMove.IsCapture()) { + killerMoves[1][ply] = killerMoves[0][ply]; + killerMoves[0][ply] = currMove; + + historyMoves[board.sideToMove][currMove.MoveFrom()][currMove.MoveTo()] += depth * depth; + } TT.WriteEntry(board.hashKey, depth, score, CutNode, Move()); return score; -- 2.47.3 From 3bb80b7d4c4c40ed742eebc2279ffccf61494379 Mon Sep 17 00:00:00 2001 From: rektdie Date: Fri, 14 Mar 2025 19:35:05 +0100 Subject: [PATCH 2/5] new move ordering values | bench 1827966 --- source/search.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/source/search.cpp b/source/search.cpp index ff22046..4983c0c 100644 --- a/source/search.cpp +++ b/source/search.cpp @@ -24,7 +24,7 @@ Stopwatch sw; static int ScoreMove(Board &board, Move &move) { TTEntry *current = TT.GetRawEntry(board.hashKey); if (current->bestMove == move) { - return 50000; + return 500000; } if (move.IsCapture()) { @@ -38,9 +38,9 @@ static int ScoreMove(Board &board, Move &move) { return moveScoreTable[attackerType][targetType] + 10000; } else { if (killerMoves[0][ply] == move) { - return 9000; + return 490000; } else if (killerMoves[1][ply] == move) { - return 8000; + return 480000; } else { return historyMoves[board.sideToMove][move.MoveFrom()][move.MoveTo()]; } -- 2.47.3 From 081cfd5431a1d2788efa7b3452e8b0b64435ee41 Mon Sep 17 00:00:00 2001 From: rektdie Date: Fri, 14 Mar 2025 19:53:14 +0100 Subject: [PATCH 3/5] storing history moves in alpha raise | bench 1183891 --- source/search.cpp | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/source/search.cpp b/source/search.cpp index ff22046..d065821 100644 --- a/source/search.cpp +++ b/source/search.cpp @@ -205,8 +205,10 @@ SearchResults PVS(Board board, int depth, int alpha, int beta) { // For all moves for (int i = 0; i < board.currentMoveIndex; i++) { + Move currMove = board.moveList[i]; + Board copy = board; - copy.MakeMove(copy.moveList[i]); + copy.MakeMove(currMove); // First move (suspected PV node) if (!i) { @@ -230,13 +232,9 @@ SearchResults PVS(Board board, int depth, int alpha, int beta) { // Fail high (beta cutoff) if (score >= beta) { - Move currMove = board.moveList[i]; - if (!currMove.IsCapture()) { killerMoves[1][ply] = killerMoves[0][ply]; killerMoves[0][ply] = currMove; - - historyMoves[board.sideToMove][currMove.MoveFrom()][currMove.MoveTo()] += depth * depth; } 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); if (score > alpha) { + if (!currMove.IsCapture()) { + historyMoves[board.sideToMove][currMove.MoveFrom()][currMove.MoveTo()] += depth * depth; + } + nodeType = PV; alpha = score; - results.bestMove = board.moveList[i]; - pvLine.SetMove(ply, board.moveList[i]); + results.bestMove = currMove; + pvLine.SetMove(ply, currMove); } } -- 2.47.3 From 326f4b9598ddad52ea2091b97d23f829f4187f5f Mon Sep 17 00:00:00 2001 From: rektdie Date: Fri, 14 Mar 2025 20:00:28 +0100 Subject: [PATCH 4/5] reverted move order values | bench 1183891 --- source/search.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/source/search.cpp b/source/search.cpp index 4d3aa9a..d065821 100644 --- a/source/search.cpp +++ b/source/search.cpp @@ -24,7 +24,7 @@ Stopwatch sw; static int ScoreMove(Board &board, Move &move) { TTEntry *current = TT.GetRawEntry(board.hashKey); if (current->bestMove == move) { - return 500000; + return 50000; } if (move.IsCapture()) { @@ -38,9 +38,9 @@ static int ScoreMove(Board &board, Move &move) { return moveScoreTable[attackerType][targetType] + 10000; } else { if (killerMoves[0][ply] == move) { - return 490000; + return 9000; } else if (killerMoves[1][ply] == move) { - return 480000; + return 8000; } else { return historyMoves[board.sideToMove][move.MoveFrom()][move.MoveTo()]; } -- 2.47.3 From 1b2f69ddf01e8bb16d1fe223c537c5894ee474fd Mon Sep 17 00:00:00 2001 From: rektdie Date: Sat, 15 Mar 2025 11:20:17 +0100 Subject: [PATCH 5/5] changed order values + little fix | bench 1146300 --- source/search.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/source/search.cpp b/source/search.cpp index d065821..8a4c38f 100644 --- a/source/search.cpp +++ b/source/search.cpp @@ -35,13 +35,14 @@ static int ScoreMove(Board &board, Move &move) { targetType = Pawn; } - return moveScoreTable[attackerType][targetType] + 10000; + return moveScoreTable[attackerType][targetType] + 30000; } else { if (killerMoves[0][ply] == move) { - return 9000; + return 20000; } else if (killerMoves[1][ply] == move) { - return 8000; + return 18000; } else { + // Max 16384 return historyMoves[board.sideToMove][move.MoveFrom()][move.MoveTo()]; } } @@ -235,6 +236,9 @@ SearchResults PVS(Board board, int depth, int alpha, int beta) { if (!currMove.IsCapture()) { killerMoves[1][ply] = killerMoves[0][ply]; killerMoves[0][ply] = currMove; + + historyMoves[board.sideToMove][currMove.MoveFrom()][currMove.MoveTo()] = + std::min(16384, historyMoves[board.sideToMove][currMove.MoveFrom()][currMove.MoveTo()] + depth * depth); } TT.WriteEntry(board.hashKey, depth, score, CutNode, Move()); @@ -244,10 +248,6 @@ SearchResults PVS(Board board, int depth, int alpha, int beta) { results.score = std::max(score, results.score); if (score > alpha) { - if (!currMove.IsCapture()) { - historyMoves[board.sideToMove][currMove.MoveFrom()][currMove.MoveTo()] += depth * depth; - } - nodeType = PV; alpha = score; results.bestMove = currMove; -- 2.47.3