algerbrex wrote: ↑Fri Oct 15, 2021 1:00 am
On the plus side, I know I’m not crazy and PVS works and gives around 50-60 Elo, so at this point all I (theoretically) have to do is slowly change your code back to mine and see at what point I introduce a bug. I’ll probably start tonight and finish sometime this weekend since I’ll be testing every change.
Note that my alpha-beta is an (extended) version of the fail-soft version here:
https://www.ics.uci.edu/~eppstein/180a/990202b.html
The difference between fail-hard and fail-soft is this:
- with fail-hard, you return the actual alpha and beta scores.
- with fail-soft, you return the best_score. That is the reason why I don't do "return beta" in the bèta cutoff, but do a "break" to jump directly after the move loop. There, I don't do "return alpha", but just "return best_score".
If used on its very own (without PVS or pruning), fail-soft will get you more precise alpha/beta values in the TT, which make a (very small) difference in playing strength because you have a few more cuts. When you use PVS, that difference all but becomes unmeasurable.
The reason why I switched to this implementation is because it's more clear to me, because:
1. you don't need to return two different values; you just return "best_score" at the end of the function.
2. you don't need to have a hash-write just before "return beta"; you just set the flag to beta, and use the hash write directly after the move loop.
3. because of 2, you can just set the hash flag to "alpha" when starting out, and set it to "beta" in the beta-cutoff, or to "exact" when you find a PV move.
4. you can save the "best_score", and the current move that goes with it, is "best_move" at that point, which is logical. So you can just write "best_score" and "best_move" as found in the move-loop into the TT; and as said, there is just one TT write point.
On that page, the author shows fail-hard, fail-soft, and PVS as different versions, but you can use PVS with either fail-hard or fail-soft. I saw no difference in playing strength between fail-hard with PVS and fail-soft with PVS, as expected. The difference is the concept and how the code looks. As said, I find it clearer than the "normal" way. (Some people also nest the "if score > alpha" and "if score >= beta" if-statements, but I like the separate way as I did in Rustic better.)
Using fail-hard or fail-soft is more a matter of taste than anything else. (But that page I linked above is the clearest explanation I could find about the difference.)
Darn. I could have written this in a neater way and put it into the website / book already.
PS: Their "current" variable is the same as my "best_score".