ordering TT moves first

This commit is contained in:
rektdie committed 2025-03-02 05:04:56 +01:00
1 parent 272fa9a04c
commit 17a0d70db0
3 files changed
+12 -5

No files matched your search

+7 -2
View File
@@ -18,6 +18,11 @@ static int ScoreMove(Board &board, Move &move) {
const int attackerType = board.GetPieceType(move.MoveFrom());
const int targetType = board.GetPieceType(move.MoveTo());
TTEntry *current = &TTable[board.hashKey % hashSize];
if (current->bestMove == move) {
return 50000;
}
if (move.IsCapture()) {
return moveScoreTable[attackerType][targetType] + 10000;
}
@@ -182,7 +187,7 @@ SearchResults PVS(Board board, int depth, int alpha, int beta) {
}
if (score >= beta) {
WriteEntry(board.hashKey, depth, beta, CutNode);
WriteEntry(board.hashKey, depth, beta, CutNode, Move());
return beta;
}
@@ -195,7 +200,7 @@ SearchResults PVS(Board board, int depth, int alpha, int beta) {
results.score = alpha;
WriteEntry(board.hashKey, depth, results.score, nodeType);
WriteEntry(board.hashKey, depth, results.score, nodeType, results.bestMove);
return results;
}
+3 -2
View File
@@ -85,7 +85,7 @@ SearchResults ReadEntry(U64 &hashKey, int depth, int alpha, int beta) {
if (current->hashKey == hashKey) {
if (current->depth >= depth) {
if (current->nodeType == PV){
return current->score;
return {current->score, current->bestMove};
} else if (current->nodeType == AllNode && current->score <= alpha) {
return alpha;
} else if (current->nodeType == CutNode && current->score >= beta) {
@@ -98,11 +98,12 @@ SearchResults ReadEntry(U64 &hashKey, int depth, int alpha, int beta) {
return invalidEntry;
}
void WriteEntry(U64 &hashKey, int depth, int score, int nodeType) {
void WriteEntry(U64 &hashKey, int depth, int score, int nodeType, Move bestMove) {
TTEntry *current = &TTable[hashKey % hashSize];
current->hashKey = hashKey;
current->nodeType = nodeType;
current->score = score;
current->depth = depth;
current->bestMove = bestMove;
}
+2 -1
View File
@@ -25,9 +25,10 @@ public:
int depth;
int score;
int nodeType;
Move bestMove;
};
extern TTEntry TTable[hashSize];
SearchResults ReadEntry(U64 &hashKey, int depth, int alpha, int beta);
void WriteEntry(U64 &hashKey, int depth, int score, int nodeType);
void WriteEntry(U64 &hashKey, int depth, int score, int nodeType, Move besteMove);