mate scores are adjusted like this
Code: Select all
int score_to_tt(int score, int ply)
{
if (score >= min_mate)
return score + ply;
else if (score <= -min_mate)
return score - ply;
else
return score;
}
int score_from_tt(int score, int ply)
{
if (score >= min_mate)
return score - ply;
else if (score <= -min_mate)
return score + ply;
else
return score;
}
Code: Select all
if (ply != 0 && e.hash == hash && e.depth >= depth) {
e.score = score_from_tt(e.score, ply);
if (e.bound >= exact_bound && e.score <= alpha)
return alpha;
if (e.bound <= exact_bound && e.score >= beta)
return beta;
if (e.bound == exact_bound && e.score > alpha && e.score < beta)
return e.score;
}
Code: Select all
if (std::abs(score) >= min_mate)
std::cout << " score mate " << (mate - std::abs(score) + 1) / 2;
else
std::cout << " score cp " << score;
Code: Select all
constexpr int max_ply = 256;
constexpr int mate = std::numeric_limits<int>::max();
constexpr int min_mate = mate - max_ply;
output from a simple position
Code: Select all
position fen 8/8/4k3/8/8/8/K7/3Q4 w - - 1 2
go
info depth 1 score cp 957 nps 31000 nodes 31 time 1 pv d1d4
info depth 2 score cp 922 nps 59000 nodes 59 time 1 pv d1d4 e6f7
info depth 3 score cp 982 nps 706000 nodes 706 time 1 pv d1d4 e6f7 d4e5
info depth 4 score cp 967 nps 1124000 nodes 1124 time 1 pv d1d4 e6f7 d4e5 f7f8
info depth 5 score cp 1020 nps 3243333 nodes 9730 time 3 pv d1d4 e6f7 a2b3 f7e8 d4d6
info depth 6 score cp 1005 nps 2709714 nodes 18968 time 7 pv a2b3 e6f5 b3c4 f5g5 d1d5 g5h4
info depth 7 score cp 1053 nps 4224684 nodes 80269 time 19 pv a2b3 e6f6 b3c4 f6e7 d1d5 e7f8 d5e6
info depth 8 score cp 1035 nps 2428653 nodes 126290 time 52 pv a2b3 e6e5 b3c4 e5f4 d1e2 f4g3 e2e4 g3h2
info depth 9 score cp 1064 nps 2892934 nodes 263257 time 91 pv a2b3 e6e5 b3c4 e5e6 c4d4 e6d6 d1e1 d6c6 e1e5
info depth 10 score cp 1064 nps 3128396 nodes 315968 time 101 pv a2b3 e6e5 b3c4 e5e6 c4d4 e6d6 d4e4 d6c7 d1d5 c7b8
info depth 11 score cp 1075 nps 4873521 nodes 794384 time 163 pv a2b3 e6e5 b3c4 e5e6 d1e2 e6f5 c4d4 f5f4 e2e4 f4g5 e4f3
info depth 12 score cp 1079 nps 4090530 nodes 740386 time 181 pv a2b3 e6e5 b3c4 e5e6 d1d3 e6e5 d3g6
info depth 13 score cp 1080 nps 4991573 nodes 1861857 time 373 pv a2b3 e6e5 b3c4 e5e6 d1d4 e6f5 c4d5 f5g5 d5e6 g5h5 d4f4 h5g6 e6d5
info depth 14 score cp 1085 nps 4354581 nodes 2739032 time 629 pv a2b2 e6e5 d1e1 e5d4 b2c2 d4c5 e1d1 c5b5
info depth 15 score cp 2147483390 nps 5012399 nodes 6195326 time 1236 pv d1f1 e6d5 f1f6 d5c4 f6e5 c4d3 a2b3 d3d2 b3b2 d2d1 e5e4
info depth 16 score mate 21 nps 4447155 nodes 2717212 time 611 pv a2b3 e6e5 b3c4 e5f5 d1h5 f5e4 h5g4
info depth 17 score mate 42 nps 4916561 nodes 3259680 time 663 pv a2b3 e6e5 b3c4 e5f5 d1h5 f5e4 c4c3 e4e3 h5h4 e3e2 h4f4
info depth 18 score mate 9 nps 4510226 nodes 3526997 time 782 pv a2b3 e6e5 b3c4 e5f5 d1h5 f5e4 h5g4 e4e5 c4c5 e5f6 c5d6 f6f7 g4g5 f7f8 d6e6 f8e8 g5e7
info depth 19 score mate 8 nps 4917595 nodes 3978335 time 809 pv a2b3 e6e5 b3c4 e5f5 d1h5 f5e4 h5g5 e4f3 c4d3 f3f2 g5g4 f2f1 d3e3 f1e1 g4g1
info depth 20 score mate 10 nps 4467138 nodes 19181893 time 4294 pv a2b3 e6f5 b3c3 f5f4 c3d4 f4f5 d4d5 f5f4 d1d3 f4g5 d5e5 g5g4 d3e3 g4h4 e3g1 h4h3 e5f4 h3h4 g1h1
info depth 21 score mate 10 nps 4890680 nodes 24311571 time 4971 pv a2b3 e6f5 b3c3 f5e5 d1f1 e5e4 f1f6 e4d5 c3d3 d5c5 f6e6 c5b5 d3d4 b5a4 d4c4 a4a3 c4c3 a3a4 e6a6