Rev 108 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 108 | Rev 154 | ||
---|---|---|---|
Line 1... | Line 1... | ||
1 | #include "chess.h" |
1 | #include "chess.h" |
2 | #include "data.h" |
2 | #include "data.h" |
3 | /* last modified |
3 | /* last modified 08/28/16 */ |
4 | /* |
4 | /* |
5 | ******************************************************************************* |
5 | ******************************************************************************* |
6 | * * |
6 | * * |
7 | * HashProbe() is used to retrieve entries from the transposition table so * |
7 | * HashProbe() is used to retrieve entries from the transposition table so * |
8 | * this sub-tree won't have to be searched again if we reach a position that * |
8 | * this sub-tree won't have to be searched again if we reach a position that * |
Line 108... | Line 108... | ||
108 | * just because it came from a previous search. * |
108 | * just because it came from a previous search. * |
109 | * * |
109 | * * |
110 | ************************************************************ |
110 | ************************************************************ |
111 | */ |
111 | */ |
112 | if (entry < 4) { |
112 | if (entry < 4) { |
113 | if (word1 >> 55 != transposition_age) { |
- | |
114 | word1 = |
- | |
115 | (word1 & 0x007fffffffffffffull) | ((uint64_t) transposition_age << |
- | |
116 | 55); |
- | |
117 | htable[entry].word1 = word1; |
- | |
118 | htable[entry].word2 = word1 ^ word2; |
- | |
119 | } |
- | |
120 | val = (word1 & 0x1ffff) - 65536; |
113 | val = (word1 & 0x1ffff) - 65536; |
121 | draft = (word1 >> 17) & 0x7fff; |
114 | draft = (word1 >> 17) & 0x7fff; |
122 | tree->hash_move[ply] = (word1 >> 32) & 0x1fffff; |
115 | tree->hash_move[ply] = (word1 >> 32) & 0x1fffff; |
123 | type = (word1 >> 53) & 3; |
116 | type = (word1 >> 53) & 3; |
124 | if ((type & UPPER) && |
117 | if ((type & UPPER) && |
Line 149... | Line 142... | ||
149 | ************************************************************ |
142 | ************************************************************ |
150 | */ |
143 | */ |
151 | switch (type) { |
144 | switch (type) { |
152 | case EXACT: |
145 | case EXACT: |
153 | if (val > alpha && val < beta) { |
146 | if (val > alpha && val < beta) { |
- | 147 | if (word1 >> 55 != transposition_age) { |
|
- | 148 | word1 = (word1 & 0x007fffffffffffffull) | ((uint64_t) |
|
- | 149 | transposition_age << 55); |
|
- | 150 | htable[entry].word1 = word1; |
|
- | 151 | htable[entry].word2 = word1 ^ word2; |
|
- | 152 | } |
|
154 | SavePV(tree, ply, 1); |
153 | SavePV(tree, ply, 1); |
155 | ptable = hash_path + (temp_hashkey & hash_path_mask); |
154 | ptable = hash_path + (temp_hashkey & hash_path_mask); |
156 | for (entry = 0; entry < 16; entry++) |
155 | for (entry = 0; entry < 16; entry++) |
157 | if (ptable[entry].path_sig == temp_hashkey) { |
156 | if (ptable[entry].path_sig == temp_hashkey) { |
158 | for (i = ply; |
157 | for (i = ply; |
Line 167... | Line 166... | ||
167 | break; |
166 | break; |
168 | } |
167 | } |
169 | } |
168 | } |
170 | return HASH_HIT; |
169 | return HASH_HIT; |
171 | case UPPER: |
170 | case UPPER: |
172 | if (val <= alpha) |
171 | if (val <= alpha) { |
- | 172 | if (word1 >> 55 != transposition_age) { |
|
- | 173 | word1 = (word1 & 0x007fffffffffffffull) | ((uint64_t) |
|
- | 174 | transposition_age << 55); |
|
- | 175 | htable[entry].word1 = word1; |
|
- | 176 | htable[entry].word2 = word1 ^ word2; |
|
- | 177 | } |
|
173 | return HASH_HIT; |
178 | return HASH_HIT; |
- | 179 | } |
|
174 | break; |
180 | break; |
175 | case LOWER: |
181 | case LOWER: |
176 | if (val >= beta) |
182 | if (val >= beta) { |
- | 183 | if (word1 >> 55 != transposition_age) { |
|
- | 184 | word1 = (word1 & 0x007fffffffffffffull) | ((uint64_t) |
|
- | 185 | transposition_age << 55); |
|
- | 186 | htable[entry].word1 = word1; |
|
- | 187 | htable[entry].word2 = word1 ^ word2; |
|
- | 188 | } |
|
177 | return HASH_HIT; |
189 | return HASH_HIT; |
- | 190 | } |
|
178 | break; |
191 | break; |
179 | } |
192 | } |
180 | } |
193 | } |
181 | return avoid_null; |
194 | return avoid_null; |
182 | } |
195 | } |
183 | return HASH_MISS; |
196 | return HASH_MISS; |
184 | } |
197 | } |
185 | 198 | ||
186 | /* last modified |
199 | /* last modified 02/12/16 */ |
187 | /* |
200 | /* |
188 | ******************************************************************************* |
201 | ******************************************************************************* |
189 | * * |
202 | * * |
190 | * HashStore() is used to store entries into the transposition table so that * |
203 | * HashStore() is used to store entries into the transposition table so that * |
191 | * this sub-tree won't have to be searched again if the same position is * |
204 | * this sub-tree won't have to be searched again if the same position is * |
Line 327... | Line 340... | ||
327 | */ |
340 | */ |
328 | if (type == EXACT) { |
341 | if (type == EXACT) { |
329 | ptable = hash_path + (temp_hashkey & hash_path_mask); |
342 | ptable = hash_path + (temp_hashkey & hash_path_mask); |
330 | for (i = 0; i < 16; i++, ptable++) { |
343 | for (i = 0; i < 16; i++, ptable++) { |
331 | if (ptable->path_sig == temp_hashkey || |
344 | if (ptable->path_sig == temp_hashkey || |
332 |
|
345 | transposition_age != ptable->hash_path_age) { |
333 | for (j = ply; j < tree->pv[ply - 1].pathl; j++) |
346 | for (j = ply; j < tree->pv[ply - 1].pathl; j++) |
334 | ptable->hash_path_moves[j - ply] = tree->pv[ply - 1].path[j]; |
347 | ptable->hash_path_moves[j - ply] = tree->pv[ply - 1].path[j]; |
335 | ptable->hash_pathl = tree->pv[ply - 1].pathl - ply; |
348 | ptable->hash_pathl = tree->pv[ply - 1].pathl - ply; |
336 | ptable->path_sig = temp_hashkey; |
349 | ptable->path_sig = temp_hashkey; |
337 | ptable->hash_path_age = transposition_age; |
350 | ptable->hash_path_age = transposition_age; |