Indeed. Marco's "surprise" confirms that he is not even reading the posts here.Michel wrote:The TB scores are saved as bounds because they are bounds.... as has been pointed out time and time again. This is not rocket science.Another interesting thing that you do is to save with LOWER / BOUND_UPPER instead of always BOUND_EXACT as it is usually done. Can you pelase elaborate on that?
Natural TB
Moderators: hgm, Rebel, chrisw
-
- Posts: 5566
- Joined: Tue Feb 28, 2012 11:56 pm
Re: Natural TB (take 2)
-
- Posts: 2684
- Joined: Sat Jun 14, 2008 9:17 pm
Re: Natural TB (take 2)
Thanks.jhellis3 wrote: Well, Bound Exact is only correct for draws, the result will never be greater than or less than a draw. But in the case of a TB win, that DTZ result implies mate eventually. To me, it certainly makes sense to treat a mate in X number of moves as greater value than mate eventually (and indeed this is the way they are actually scored in the engine), so use Bound Lower. Same principle applies to being mated.
I have tested with both the ideas I saw in your code:
Code: Select all
1. Save in TT with bounds instead of exact scores
2. Always save in TT even if search is continued (as in the case of winning position)
This is a 3minutes game SF Natural against itself with 5-men TB starting form this position
[D]8/8/4r3/4k3/8/1K2P3/3P4/6R1 w - - 1 46
This is the game with both above ideas applied:
Code: Select all
1. d4+ +3.75/23 7.4s Kf6 -4.58/27 13s
2. Rg3 +4.00/23 1.4s Ke7 -5.42/26 11s
3. Kc4 +4.14/23 1.3s Kd6 -6.05/27 5.3s
4. Kd3 +5.07/24 3.0s Kd5 -7.87/28 11s
5. e4+ +6.14/23 1.3s Kd6 -9.70/24 4.0s
6. Rg7 +6.61/20 0.48s Rh6 -10.97/25 4.1s
7. Kc4 +8.73/22 1.9s Rh1 -12.15/26 12s
8. e5+ +10.97/22 3.1s Ke6 -21.19/24 6.7s
9. Rg6+ +11.76/19 1.4s Kf7 -47.50/24 5.9s
10. Ra6 +21.08/20 1.8s Rc1+ -128.72/24 10s
11. Kd5 +132.62/21 2.7s Rc8 -132.65/26 5.0s
12. Ra7+ +132.63/22 2.3s Kg6 -132.66/25 9.5s
13. e6 +132.65/22 2.6s Re8 -132.64/23 1.8s
14. e7 +132.65/21 4.3s Kf7 -132.66/23 2.0s
15. Kd6 +132.65/24 9.4s Kf6 -132.68/21 0.39s
16. Ra6 +132.69/18 0.78s Kf7 -132.57/23 8.9s
17. Ra4 +132.69/23 6.7s Rb8 -132.62/19 2.0s
18. e8=Q+ +132.77/24 15s Rxe8 -2.63/16 1.0s
19. d5 +5.76/17 4.8s Rg8 -10.73/17 5.3s
20. Ra7+ +132.71/18 13s Kf6 -2.70/15 1.3s
21. Ra2 +4.29/18 12s Rg4 -47.46/17 5.5s
22. Rf2+ +57.90/15 3.0s Kg7 -58.03/17 2.8s
23. Kc6 +132.70/16 2.1s Ra4 -58.11/16 2.1s
24. d6 +132.69/17 2.6s Rg4 -132.71/16 2.4s
25. Rc2 +132.68/17 3.6s Re4 -52.81/16 3.6s
26. Rg2+ +132.69/15 2.4s Kf6 -132.67/19 5.1s
27. d7 +132.62/16 3.3s Rd4 -47.63/15 0.64s
28. Kc7 +132.70/17 6.9s Rc4+ -52.95/16 5.4s
29. Kd6 +64.45/18 8.6s Rd4+ -132.78/21 4.7s
30. Kc7 +132.52/19 7.5s Rc4+ -132.68/15 0.52s
31. Kd6 +132.70/18 0.88s Rd4+ -59.68/19 4.1s
32. Kc6 +132.69/18 1.9s Ke6 -132.69/17 1.2s
33. Re2+ +132.69/17 1.9s Kf6 -132.70/14 0.10s
34. Kc7 +132.72/15 1.1s Rc4+ -132.62/17 2.7s
35. Kb6 +132.71/17 1.7s Rd4 -64.57/19 3.0s
36. Kc6 +48.33/20 5.8s Kg7 -52.65/15 0.42s
37. Rg2+ +132.72/16 1.3s Kf6 -47.80/16 0.43s
38. Re2 +132.70/17 2.0s Rd3 -132.56/19 2.5s
39. Re3 +47.75/17 4.6s Rxd7 -132.68/17 1.1s
40. Kxd7 +132.70/19 1.7s Kf5 -132.69/17 0.48s
41. Kd8 +132.71/17 3.6s Kf4 -47.63/15 1.0s
42. Ra3 +132.70/15 0.69s Ke4 -132.67/17 0.77s
43. Kc7 +47.83/16 2.9s Kd4 -47.80/14 0.25s
44. Kb7 +132.69/15 0.65s Kc4 -48.16/17 1.6s
45. Rg3 +47.71/15 2.4s Kd5 -132.70/17 0.40s
46. Rf3 +132.73/14 0.25s Ke4 -48.08/17 1.3s
47. Rf1 +132.70/15 1.0s Ke3 -47.80/12 0.13s
48. Ra1 +132.70/17 1.8s Kd2 -132.71/14 0.42s
49. Ka7 +47.71/13 0.83s Ke2 -132.70/14 0.21s
50. Ra2+ +132.72/15 0.29s Ke1 -47.80/14 0.27s
51. Kb7 +47.67/14 0.77s Kd1 -47.71/14 0.60s
52. Kc6 +47.67/13 0.44s Ke1 -132.71/15 0.22s
53. Rc2 +132.68/13 0.13s Kf1 -48.33/17 0.76s
54. Kd6 +132.66/15 0.37s Ke1 -132.70/14 0.27s
55. Kd5 +132.70/14 0.93s Kd1 -47.80/13 0.096s
56. Ra2 +M17/15 0.11s Kc1 -M14/32 0.15s
57. Kd4 +M13/29 0.10s Kd1 -M12/33 0.075s
58. Kc3 +M11/27 0.022s Ke1 -M10/36 0.080s
59. Kd3 +M9/35 0.11s Kf1 -M8/37 0.016s
60. Ke3 +M7/37 0.022s Kg1 -M6/92 0.070s
61. Kf3 +M5/127 0.061s Kh1 -M4/127 0.005s
62. Kg3 +M3/127 0.005s Kg1 -M2/1 0s
63. Ra1#
+M1/127 0.003s, White mates
Code: Select all
1. Kc4 +2.59/23 6.3s Rc6+ -2.42/21 4.0s
2. Kd3 +2.68/23 1.3s Ra6 -2.67/28 4.7s
3. Rg5+ +2.82/24 0.59s Kf6 -2.80/29 0.86s
4. Rc5 +2.92/27 1.4s Ke7 -3.47/25 5.3s
5. e4 +3.75/22 1.7s Kd6 -3.72/24 1.0s
6. Kd4 +5.12/24 2.2s Ke6 -6.04/25 6.1s
7. e5 +7.15/26 5.1s Ra4+ -7.94/27 7.6s
8. Rc4 +7.16/25 0.57s Ra2 -8.58/25 1.3s
9. Rc6+ +7.25/32 1.4s Ke7 -10.55/30 14s
10. d3 +9.11/25 3.3s Ra3 -11.08/26 6.7s
11. Ke4 +10.02/22 1.5s Kf7 -12.16/26 13s
12. d4 +11.16/21 1.7s Rh3 -21.60/24 12s
13. Rc7+ +14.20/21 2.8s Kg6 -47.63/25 7.3s
14. e6 +21.19/21 1.4s Rh5 -52.81/27 5.9s
15. Rf7 +47.55/22 2.7s Rh1 -52.77/25 8.4s
16. Ke5 +132.50/21 2.7s Rh5+ -132.64/21 3.2s
17. Kd6 +132.65/21 2.9s Rh4 -52.81/19 4.3s
18. d5 +132.60/23 6.0s Ra4 -M44/30 4.0s
19. Ke5 +132.60/24 3.0s Ra6 -M40/29 1.4s
20. Rf8 +132.64/20 8.3s Ra7 -M36/30 0.40s
21. Rf6+ +M47/22 0.59s Kg7 -M32/31 1.6s
22. Rf7+ +M27/44 1.4s Rxf7 -M30/33 0.24s
23. exf7 +M25/44 0.44s Kxf7 -M26/38 1.5s
24. d6 +M23/50 3.0s Kf8 -M22/44 1.5s
25. Kf6 +M21/51 0.58s Ke8 -M20/44 0.35s
26. Ke6 +M19/55 2.3s Kd8 -M18/50 1.4s
27. d7 +M17/55 1.3s Kc7 -M16/1 0s
28. Ke7 +M15/55 2.6s Kb6 -M14/51 2.2s
29. d8=Q+ +M13/56 2.4s Kc5 -M12/46 0.24s
30. Qd3 +M11/56 0.45s Kc6 -M10/59 1.4s
31. Qc4+ +M9/87 2.2s Kb7 -M8/127 1.1s
32. Kd6 +M7/127 0.80s Kb8 -M6/127 0.087s
33. Qb4+ +M5/127 0.050s Ka7 -M4/127 0.067s
34. Kc6 +M3/127 0.004s Ka6 -M2/127 0.003s
35. Qa3#
+M1/127 0.003s, White mates
BTW the second idea "Always save in TT even if search is continued" it is a pattern completely new to me, I never saw such a pattern before in a chess engine.
-
- Posts: 2684
- Joined: Sat Jun 14, 2008 9:17 pm
Re: Natural TB (take 2)
As a reference, this is the TB code as of today:
Code: Select all
// Step 4a. Tablebase probe
if (!PvNode && ss->tbCardinality)
{
int piecesCount = pos.count<ALL_PIECES>();
if ( piecesCount <= ss->tbCardinality
&& (piecesCount < ss->tbCardinality || depth >= TB::ProbeDepth)
&& !pos.can_castle(ANY_CASTLING))
{
TB::ProbeState err;
TB::WDLScore wdl = Tablebases::probe_wdl(pos, &err);
if (err != TB::ProbeState::FAIL)
{
thisThread->tbHits.fetch_add(1, std::memory_order_relaxed);
int drawScore = TB::UseRule50 ? 1 : 0;
value = wdl < -drawScore ? -VALUE_MATE + MAX_PLY + ss->ply
: wdl > drawScore ? VALUE_MATE - MAX_PLY - ss->ply
: VALUE_DRAW + 2 * wdl * drawScore;
// Use TB scores win/loss as bounds (like TT upperbound and
// lowerbound scores), a draw score is always considered.
if (value >= beta ? wdl >= TB::WDLDraw : wdl <= TB::WDLDraw)
{
Bound b = wdl > TB::WDLDraw ? BOUND_LOWER
: wdl < TB::WDLDraw ? BOUND_UPPER : BOUND_EXACT;
// In case of a draw or a loss, save TB score in TT and return
// In case of a winning position keep searching the sub-tree
// with a much reduced depth and do not probe TB anymore.
if (value <= VALUE_DRAW)
{
tte->save(posKey, value_to_tt(value, ss->ply), b,
std::min(DEPTH_MAX - ONE_PLY, depth + 6 * ONE_PLY),
MOVE_NONE, VALUE_NONE, TT.generation());
return value;
}
depth = std::max(depth / 2, ONE_PLY);
ss->tbCardinality = 0;
}
}
}
}
-
- Posts: 2684
- Joined: Sat Jun 14, 2008 9:17 pm
Re: Natural TB (take 2)
Here is the result of this test set:
https://chessprogramming.wikispaces.com ... dgame+Test
5-men, 15 sec per position, single core Intel-i5 2.6 Ghz
https://chessprogramming.wikispaces.com ... dgame+Test
5-men, 15 sec per position, single core Intel-i5 2.6 Ghz
Code: Select all
stockfish: Found 145 tablebases
Solving: D:\Documents\chess tests\endgame\Eigenmann Endgame Test.cbh
Maximum time = 15s.
2. E_E_T 003 - B vs B, Eigenmann Endgame Test Solved in 1.59s/22; Solved: 1
3. E_E_T 006 - B vs L, Eigenmann Endgame Test Solved in 0.28s/18; Solved: 2
4. E_E_T 007 - B vs L, Eigenmann Endgame Test Solved in 0.50s/23; Solved: 3
5. E_E_T 008 - B vs S, Eigenmann Endgame Test Solved in 0.30s/17; Solved: 4
6. E_E_T 009 - B vs S, Eigenmann Endgame Test Solved in 0.42s/17; Solved: 5
7. E_E_T 010 - B vs S, Eigenmann Endgame Test Solved in 1.05s/23; Solved: 6
8. E_E_T 011 - D vs D, Eigenmann Endgame Test Solved in 0.20s/11; Solved: 7
9. E_E_T 012 - D vs D, Eigenmann Endgame Test Solved in 0.08s/14; Solved: 8
10. E_E_T 013 - D vs D&S, Eigenmann Endgame Test Solved in 11.31s/43; Solved: 9
11. E_E_T 014 - D&L vs D&T, Eigenmann Endgame Test Solved in 0.36s/16; Solved: 10
12. E_E_T 015 - D&L&L vs D&L&S, Eigenmann Endgame Test Solved in 4.49s/34; Solved: 11
13. E_E_T 017 - D&T&L vs D&L&L, Eigenmann Endgame Test Solved in 3.03s/22; Solved: 12
14. E_E_T 018 - D&T&S vs D&T&T, Eigenmann Endgame Test Solved in 0.05s/11; Solved: 13
15. E_E_T 019 - D&T&T vs D&T&T, Eigenmann Endgame Test Solved in 0.59s/17; Solved: 14
16. E_E_T 020 - L vs B, Eigenmann Endgame Test Solved in 0.08s/13; Solved: 15
17. E_E_T 021 - L vs B, Eigenmann Endgame Test Solved in 0.33s/19; Solved: 16
18. E_E_T 022 - L vs L, Eigenmann Endgame Test Solved in 5.09s/26; Solved: 17
19. E_E_T 023 - L vs L, Eigenmann Endgame Test Solved in 0.06s/14; Solved: 18
20. E_E_T 024 - L vs L, Eigenmann Endgame Test Solved in 3.18s/25; Solved: 19
21. E_E_T 025 - L vs L, Eigenmann Endgame Test Solved in 0.53s/17; Solved: 20
22. E_E_T 027 - L vs L, Eigenmann Endgame Test Solved in 0s/8; Solved: 21
23. E_E_T 028 - L vs L, Eigenmann Endgame Test Solved in 2.67s/42; Solved: 22
24. E_E_T 029 - L vs S, Eigenmann Endgame Test Solved in 3.20s/27; Solved: 23
25. E_E_T 030 - L vs S, Eigenmann Endgame Test Solved in 0.11s/15; Solved: 24
26. E_E_T 031 - L vs S, Eigenmann Endgame Test Solved in 0.13s/14; Solved: 25
27. E_E_T 032 - L&L&S vs T&L&L, Eigenmann Endgame Test Solved in 2.47s/19; Solved: 26
28. E_E_T 033 - L&S vs D, Eigenmann Endgame Test > 15s.
29. E_E_T 034 - L&S vs L&B, Eigenmann Endgame Test > 15s.
30. E_E_T 035 - L&S vs L&S, Eigenmann Endgame Test Solved in 11.92s/34; Solved: 27
31. E_E_T 036 - L&S vs T&B, Eigenmann Endgame Test Solved in 6.97s/40; Solved: 28
32. E_E_T 037 - L&S&S vs T&B, Eigenmann Endgame Test > 15s.
33. E_E_T 038 - S vs B, Eigenmann Endgame Test Solved in 0.03s/13; Solved: 29
34. E_E_T 039 - S vs D, Eigenmann Endgame Test > 15s.
35. E_E_T 040 - S vs L, Eigenmann Endgame Test Solved in 0.17s/16; Solved: 30
36. E_E_T 041 - S vs L, Eigenmann Endgame Test Solved in 0.45s/21; Solved: 31
37. E_E_T 042 - S vs L, Eigenmann Endgame Test Solved in 3.82s/24; Solved: 32
38. E_E_T 043 - S vs L, Eigenmann Endgame Test Solved in 0.06s/17; Solved: 33
39. E_E_T 044 - S vs S, Eigenmann Endgame Test Solved in 0.39s/20; Solved: 34
40. E_E_T 045 - S vs S, Eigenmann Endgame Test Solved in 1.12s/23; Solved: 35
41. E_E_T 046 - S vs S, Eigenmann Endgame Test Solved in 0.05s/13; Solved: 36
42. E_E_T 047 - S vs T, Eigenmann Endgame Test Solved in 3.59s/27; Solved: 37
43. E_E_T 048 - S vs T, Eigenmann Endgame Test Solved in 3.32s/26; Solved: 38
44. E_E_T 049 - T vs B, Eigenmann Endgame Test Solved in 1.97s/24; Solved: 39
45. E_E_T 050 - T vs B, Eigenmann Endgame Test Solved in 0.86s/16; Solved: 40
46. E_E_T 051 - T vs L, Eigenmann Endgame Test Solved in 0.23s/16; Solved: 41
47. E_E_T 052 - T vs L, Eigenmann Endgame Test Solved in 0.23s/16; Solved: 42
48. E_E_T 053 - T vs S, Eigenmann Endgame Test Solved in 0.03s/12; Solved: 43
49. E_E_T 054 - T vs T, Eigenmann Endgame Test Solved in 1.42s/22; Solved: 44
50. E_E_T 055 - T vs T, Eigenmann Endgame Test Solved in 10.53s/29; Solved: 45
51. E_E_T 056 - T vs T, Eigenmann Endgame Test Solved in 0.94s/19; Solved: 46
52. E_E_T 057 - T vs T, Eigenmann Endgame Test Solved in 0.17s/14; Solved: 47
53. E_E_T 058 - T vs T, Eigenmann Endgame Test Solved in 4.79s/27; Solved: 48
54. E_E_T 059 - T vs T, Eigenmann Endgame Test Solved in 0.23s/15; Solved: 49
55. E_E_T 060 - T vs T, Eigenmann Endgame Test Solved in 6.58s/37; Solved: 50
56. E_E_T 061 - T vs T, Eigenmann Endgame Test Solved in 0.05s/13; Solved: 51
57. E_E_T 062 - T vs T, Eigenmann Endgame Test Solved in 4.07s/30; Solved: 52
58. E_E_T 063 - T vs T, Eigenmann Endgame Test Solved in 4.45s/30; Solved: 53
59. E_E_T 064 - T vs T, Eigenmann Endgame Test Solved in 4.24s/24; Solved: 54
60. E_E_T 065 - T vs T, Eigenmann Endgame Test > 15s.
61. E_E_T 066 - T vs T, Eigenmann Endgame Test Solved in 2.09s/22; Solved: 55
62. E_E_T 067 - T vs T, Eigenmann Endgame Test Solved in 0.09s/12; Solved: 56
63. E_E_T 068 - T vs T, Eigenmann Endgame Test > 15s.
64. E_E_T 069 - T vs T, Eigenmann Endgame Test Solved in 0.59s/17; Solved: 57
65. E_E_T 071 - T&L vs D, Eigenmann Endgame Test Solved in 0.89s/15; Solved: 58
66. E_E_T 072 - T&L vs L&B, Eigenmann Endgame Test Solved in 0.58s/17; Solved: 59
67. E_E_T 073 - T&L vs T&B, Eigenmann Endgame Test Solved in 0.02s/10; Solved: 60
68. E_E_T 074 - T&L vs T&B, Eigenmann Endgame Test Solved in 3.60s/22; Solved: 61
69. E_E_T 075 - T&L vs T&L, Eigenmann Endgame Test Solved in 0s/6; Solved: 62
70. E_E_T 076 - T&L vs T&L, Eigenmann Endgame Test Solved in 3.07s/23; Solved: 63
71. E_E_T 077 - T&L vs T&L, Eigenmann Endgame Test > 15s.
72. E_E_T 078 - T&L vs T&S, Eigenmann Endgame Test Solved in 4.52s/27; Solved: 64
73. E_E_T 079 - T&L&L vs T&L&S, Eigenmann Endgame Test Solved in 0.14s/14; Solved: 65
74. E_E_T 080 - T&L&S vs D&L, Eigenmann Endgame Test Solved in 8.75s/27; Solved: 66
75. E_E_T 081 - T&L&S vs L&B, Eigenmann Endgame Test Solved in 4.51s/42; Solved: 67
76. E_E_T 082 - T&L&S vs T&L&L, Eigenmann Endgame Test Solved in 12.14s/27; Solved: 68
77. E_E_T 083 - T&L&S vs T&L&S, Eigenmann Endgame Test Solved in 0s/7; Solved: 69
78. E_E_T 084 - T&S vs T&L, Eigenmann Endgame Test Solved in 0.03s/12; Solved: 70
79. E_E_T 085 - T&S vs T&L, Eigenmann Endgame Test Solved in 15.24s/27; Solved: 71
80. E_E_T 086 - T&S vs T&L, Eigenmann Endgame Test Solved in 0.06s/11; Solved: 72
81. E_E_T 087 - T&S vs T&S, Eigenmann Endgame Test Solved in 0.25s/15; Solved: 73
82. E_E_T 088 - T&S vs T&S, Eigenmann Endgame Test > 15s.
83. E_E_T 089 - T&S vs T&T, Eigenmann Endgame Test Solved in 3.49s/19; Solved: 74
84. E_E_T 090 - T&S&B vs T&T&L, Eigenmann Endgame Test Solved in 0s/3; Solved: 75
85. E_E_T 090 - T&T vs D, Eigenmann Endgame Test Solved in 0.02s/9; Solved: 76
86. E_E_T 092 - T&T vs T&L, Eigenmann Endgame Test Solved in 0.51s/18; Solved: 77
87. E_E_T 093 - T&T vs T&L&S, Eigenmann Endgame Test Solved in 1.17s/16; Solved: 78
88. E_E_T 094 - T&T vs T&T, Eigenmann Endgame Test Solved in 0.05s/10; Solved: 79
89. E_E_T 095 - T&T vs T&T, Eigenmann Endgame Test Solved in 3.54s/24; Solved: 80
90. E_E_T 096 - T&T&L vs D&L&L, Eigenmann Endgame Test Solved in 6.57s/22; Solved: 81
91. E_E_T 097 - T&T&L vs T&S&B, Eigenmann Endgame Test Solved in 1.98s/20; Solved: 82
92. E_E_T 098 - T&T&L vs T&T&L, Eigenmann Endgame Test > 15s.
93. E_E_T 099 - T&T&S vs T&T&L, Eigenmann Endgame Test Solved in 0.09s/12; Solved: 83
94. E_E_T 100 - T&T&S vs T&T&L, Eigenmann Endgame Test Solved in 3.35s/21; Solved: 84
95. E_E_T 16b - T&S vs T&S, Eigenmann Endgame Test Solved in 3.67s/22; Solved: 85
96. E_E_T 26b - L vs L, Eigenmann Endgame Test Solved in 0.41s/17; Solved: 86
97. E_E_T 70b - D vs T&L&B, Eigenmann Endgame Test Solved in 0s/4; Solved: 87
98. E_E_T 001 - B vs B, Eigenmann Endgame Test Solved in 0.30s/18; Solved: 88
99. E_E_T 002 - B vs B, Eigenmann Endgame Test Solved in 0.70s/17; Solved: 89
100. E_E_T 004 - B vs B, Eigenmann Endgame Test Solved in 0.42s/16; Solved: 90
101. E_E_T 005 - B vs B, Eigenmann Endgame Test > 15s.
Result: 90 out of 100 = 90.0%. Average time = 2.19s / 19.62
-
- Posts: 2684
- Joined: Sat Jun 14, 2008 9:17 pm
Re: Natural TB (take 2)
As a reference current version under same conditions did:
Code: Select all
stockfish: Found 145 tablebases
Solving: D:\Documents\chess tests\endgame\Eigenmann Endgame Test.cbh
Maximum time = 15s.
Result: 88 out of 100 = 88.0%. Average time = 1.61s / 18.61
-
- Posts: 546
- Joined: Sat Aug 17, 2013 12:36 am
Re: Natural TB (take 2)
Hi Marco. I am not sure how exactly you implemented the condition, but I don't always save to the TT. In fact, my implementation does not even use the TBs if a "correct" ttValue is detected, greater than KNOWN_WIN for a win, less that -KNOWN_WIN for a loss.BTW the second idea "Always save in TT even if search is continued" it is a pattern completely new to me, I never saw such a pattern before in a chess engine.
The idea behind saving though is, that since we are not returning, in the case that we detect an incorret ttValue or no ttValue at all, we (over)write that to the TT. All reduced depth searches (which is prettymuch everything other than the PV), will be able to take advantage of this. The idea being that if we have access to perfect information about a position, we can use it as a soft guide to the search. This can as you noticed lead to some search instability, but I do not recall it being quite that severe in my implementation. It has been quite some time since I last looked at or worked on the code, however.
One thing I did noticed about your method is you have:
Code: Select all
if (value <= VALUE_DRAW)
{
tte->save(posKey, value_to_tt(value, ss->ply), b,
std::min(DEPTH_MAX - ONE_PLY, depth + 6 * ONE_PLY),
MOVE_NONE, VALUE_NONE, TT.generation());
return value;
}
Code: Select all
if (wdl <= drawScore)
Anyway, hope that helps. I may take a look at the code again when I get some more free time. [/quote]
-
- Posts: 2684
- Joined: Sat Jun 14, 2008 9:17 pm
Re: Natural TB (take 2)
Thanks Joseph, yes you are right. I have rewritten the logic to accomplish following goals:jhellis3 wrote: But shouldn't the condition here be:Code: Select all
if (wdl <= drawScore)
Code: Select all
- Full symmety between win and lose positions
- Full symmetry between PV and non-PV nodes (it probes also in PV nodes)
- Full efficency when TB hit is deep in the tree (midgame)
- Full efficency to detect draw positions
- Normal search and scores during endgames
Now I have to pit it against master in a long test to verify we, hopefully, don't have lost ELO.
I have pushed the version on Github, the core of new version logic is the following:
Code: Select all
// Step 4a. Tablebase probe
if (!rootNode && ss->tbCardinality)
{
int piecesCount = pos.count<ALL_PIECES>();
if ( piecesCount <= ss->tbCardinality
&& (piecesCount < ss->tbCardinality || depth >= TB::ProbeDepth)
&& !pos.can_castle(ANY_CASTLING))
{
TB::ProbeState err;
TB::WDLScore wdl = Tablebases::probe_wdl(pos, &err);
if (err != TB::ProbeState::FAIL)
{
thisThread->tbHits.fetch_add(1, std::memory_order_relaxed);
int drawScore = TB::UseRule50 ? 1 : 0;
value = wdl < -drawScore ? -VALUE_MATE + MAX_PLY + ss->ply
: wdl > drawScore ? VALUE_MATE - MAX_PLY - ss->ply
: VALUE_DRAW + 2 * wdl * drawScore;
// Use TB scores win/loss as bounds (like TT upperbound and
// lowerbound scores), a draw score is always considered.
if (value >= beta ? wdl >= TB::WDLDraw : wdl <= TB::WDLDraw)
{
Bound b = wdl > TB::WDLDraw ? BOUND_LOWER
: wdl < TB::WDLDraw ? BOUND_UPPER : BOUND_EXACT;
bool farFromRoot = ss->ply - depth / (2 * ONE_PLY) >= 0;
// When draw or in midgame save TB score in TT and return
if (farFromRoot || wdl == TB::WDLDraw)
{
tte->save(posKey, value_to_tt(value, ss->ply), b,
std::min(DEPTH_MAX - ONE_PLY, depth + 6 * ONE_PLY),
MOVE_NONE, VALUE_NONE, TT.generation());
return value;
}
// When in endgame proceed with a reduced search
depth = depth / 2;
ss->tbCardinality = 0;
}
}
}
}
-
- Posts: 658
- Joined: Wed Mar 08, 2006 8:58 pm
Re: Natural TB (take 2)
not working.
kind regards
Code: Select all
g++ -Wall -Wcast-qual -std=c++11 -march=native -mtune=native -Wextra -Wshadow -DNDEBUG -march=native -mtune=native -Ofast -fno-tracer -DIS_64BIT -march=native -march=native -mpopcnt -DUSE_POPCNT -c -o search.o search.cpp
search.cpp: In function 'Value {anonymous}::search(Position&, Search::Stack*, Value, Value, Depth, bool, bool)':
search.cpp:707:24: error: 'struct Search::Stack' has no member named 'tbCardinality'
if (!PvNode && ss->tbCardinality)
^~~~~~~~~~~~~
search.cpp:711:36: error: 'struct Search::Stack' has no member named 'tbCardinality'
if ( piecesCount <= ss->tbCardinality
^~~~~~~~~~~~~
search.cpp:712:36: error: 'struct Search::Stack' has no member named 'tbCardinality'
&& (piecesCount < ss->tbCardinality || depth >= TB::ProbeDepth)
^~~~~~~~~~~~~
search.cpp:747:25: error: 'struct Search::Stack' has no member named 'tbCardinality'
ss->tbCardinality = 0;
^~~~~~~~~~~~~
<builtin>: recipe for target 'search.o' failed
mingw32-make[1]: *** [search.o] Error 1
mingw32-make[1]: Leaving directory 'C:/Users/bbauer/linscott/mysrc'
Makefile:438: recipe for target 'build' failed
mingw32-make: *** [build] Error 2
-
- Posts: 5566
- Joined: Tue Feb 28, 2012 11:56 pm
Re: Natural TB (take 2)
You need all the changes and not just those posted here. Try this:BBauer wrote:not working.kind regardsCode: Select all
g++ -Wall -Wcast-qual -std=c++11 -march=native -mtune=native -Wextra -Wshadow -DNDEBUG -march=native -mtune=native -Ofast -fno-tracer -DIS_64BIT -march=native -march=native -mpopcnt -DUSE_POPCNT -c -o search.o search.cpp search.cpp: In function 'Value {anonymous}::search(Position&, Search::Stack*, Value, Value, Depth, bool, bool)': search.cpp:707:24: error: 'struct Search::Stack' has no member named 'tbCardinality' if (!PvNode && ss->tbCardinality) ^~~~~~~~~~~~~ search.cpp:711:36: error: 'struct Search::Stack' has no member named 'tbCardinality' if ( piecesCount <= ss->tbCardinality ^~~~~~~~~~~~~ search.cpp:712:36: error: 'struct Search::Stack' has no member named 'tbCardinality' && (piecesCount < ss->tbCardinality || depth >= TB::ProbeDepth) ^~~~~~~~~~~~~ search.cpp:747:25: error: 'struct Search::Stack' has no member named 'tbCardinality' ss->tbCardinality = 0; ^~~~~~~~~~~~~ <builtin>: recipe for target 'search.o' failed mingw32-make[1]: *** [search.o] Error 1 mingw32-make[1]: Leaving directory 'C:/Users/bbauer/linscott/mysrc' Makefile:438: recipe for target 'build' failed mingw32-make: *** [build] Error 2
https://github.com/mcostalba/Stockfish/ ... tural2.zip
-
- Posts: 919
- Joined: Tue Nov 24, 2015 9:11 pm
- Location: upstate
Re: Natural TB (take 2)
Simply amazing.MikeB wrote:The generation time is ultimately based the size of the TB's. Using a 12 core Mac Pro with slightly older CPUs (x5690) was able to generate syzygy all 6 Man EGTB's in less than 72 hours - let's call it 60 hours . This is about 150 GB.Nordlandia wrote: How long will it take to generate 5-men syzygy in DTM format on high-end hardware (in my case i7-5960X 8-core) and estimated volume with good compression technique?