Dan Honeycutt wrote:
(2) When you store and probe you MUST get back exactly what you put in. This is simple in concept but errors can easily creep in.
(3) If you use the hash to cut your logic to handle the bounds, remaining depth and so on must be correct.
Few comments, that might be worth mentioning:
(2) Depending how you define put in and get back, this is not the case for mate scores for typical engines. Dan's code shows, that he adjusts the mate scores by "ply". Of course, the value stored in the HT literally is the one you get back. But if you define the store/probe as the values given to tHe HashStore() and got back by HashProbe() they will differ in general for mate scores. (Long ago Miguel Ballicora showed a slightly different search scheme for mate values, were bounds get adjusted inside the search. I forgot the details, but I believe remember, that the HT scores for mates did not need any adjustment.)
(3) Also here mate scores can be an exception. Not only for the adjustment of scores, but also for cutoffs. Even when the draft would not be enough for a non mate score cutoff/bounds adjustment, a mate score (which is always a really proven score) will be enough (not for cutoffs inside the window - then you could lose the ability to find the shortest mate), but for fail high/ fail low. In some positions this can reduce the search tree by a significant amount (for fail soft searchers). But such ideas probably should only be implemented when the hash logic is well debugged. The same probably is already true for all bound adjustments. I am not sure, how much they buy, and got different results. Bob Hyatt recently mentioned, that he dumped the bounds adjustments totally.
Another subtle point in this context. Say you have a lower bound with enough draft, but not good enough to give you a cutoff (the lower bound is inside your current search window). You might want to adjust alpha to this lower bound. But it can happen, that this lower bound is really an exact score (you cannot know it at this time). When you adjusted alpha to this lower bound that actually is exact, you may end up without any best mvoe easily. This might hurt (for example you will not have a best move in the HT when you visit this node next, while with the not adjusted bound, you had such a move). Adjusting alpha = lower_bound -1 might help. I tried it, but it was not always convincing. I have many #defines to adjust the behavior.
Depending on the engine, storing negative draft may make sense. For example for qsearch nodes.
Regards,
Dieter