Skip to content

Commit 66af0b5

Browse files
mate scoring correction
1 parent d58c297 commit 66af0b5

File tree

2 files changed

+8
-11
lines changed

2 files changed

+8
-11
lines changed

src/Search.cpp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,7 @@
77
#include <thread>
88
#include <format>
99

10-
#ifdef wasm
11-
#include "emscripten.h"
12-
#endif
13-
14-
#define MATE_SCORE 65536
10+
#define MATE_SCORE 32768 // 1 << 15
1511

1612
TranspositionTable Search::tt = TranspositionTable();
1713

src/TranspositionTable.cpp

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,16 @@
44

55
#include "MoveGenerator.h"
66

7-
#define MATE_SCORE 65536
7+
#define MATE_SCORE 32768 // 1 << 15
8+
#define MIN_MATE_SCORE 16384 // 1 << 14
89

910
TranspositionTable::Entry TranspositionTable::getEntry(const uint64_t key, const int ply) {
1011
const int index = key % TT_SIZE;
1112
Entry entry = entries[index];
1213

13-
if (abs(entry.score) == MATE_SCORE) {
14-
int sign = entry.score > 0 ? 1 : -1;
15-
entry.score = sign * (MATE_SCORE - ply);
14+
if (abs(entry.score) >= MIN_MATE_SCORE) {
15+
const int sign = entry.score > 0 ? 1 : -1;
16+
entry.score = sign * (abs(entry.score) - ply);
1617
}
1718
reads++;
1819

@@ -31,9 +32,9 @@ bool TranspositionTable::contains(const uint64_t key) {
3132
void TranspositionTable::setEntry(const ChessBoard&board, const Move bestMove, const int depth, int score, const NodeType nodeType, const int ply) {
3233
const int index = board.hashCode % TT_SIZE;
3334

34-
if (abs(score) >= MATE_SCORE - (depth + ply)) {
35+
if (abs(score) >= MIN_MATE_SCORE) {
3536
const int sign = score > 0 ? 1 : -1;
36-
score = sign * MATE_SCORE;
37+
score = sign * (abs(score) + ply);
3738
}
3839

3940
const NodeType savedType = entries[index].nodeType;

0 commit comments

Comments
 (0)