-
Notifications
You must be signed in to change notification settings - Fork 2.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve commentary about DEPTH constants #5205
Conversation
clang-format 17 needs to be run on this PR. (execution 9154229307 / attempt 1) |
src/types.h
Outdated
DEPTH_NONE = -6, | ||
|
||
DEPTH_OFFSET = -7 // value used only for TT entry occupancy check | ||
// In QS, with depth <= 0, we search only "tactical" moves to fight the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fighting against the horizon effect is only a subproduct of qsearch, the idea is to have a more stable static evaluation of the position such that there are no tactical solutions left, that could render the static evaluation useless.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i.e. if our evaluation function is as good in evaluating the tactical positions as it is good for quiet positions, we don't need no qsearch at all. you can just return eval.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the idea is to have a more stable static evaluation of the position such that there are no tactical solutions left, that could render the static evaluation useless.
this is part of what is meant by "the horizon effect" no?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we search only "tactical" moves to fight the horizon effect.
well, my nitpick is that searching (only "tactical" moves) does not fight against the horizon effect and hints that if you try any other moves you will get horizoned, which is not accurate, you will get an explosion and not neccessarly a horizon effect.
rather I find something like "because the horizon effect is more detrimental in the tactical positions we limit searching to them, otherwise we trust the evaluation function"
more to the point and less misleading.
aca4195
to
b3dd845
Compare
I've pushed a new version with cj's constant names, and expanding the comment based on peregrine's concerns |
Note really my taste, like reading the comments I run into terms that I find non-standard unclear.
I don't think prexisting comments were wrong or misleading, so I would probably not merge this one, as per previous suggestion by @Disservin |
I don't have something against new comments which explain logic.. reordering of words is also mostly useless because it also very much a personal choice. I do think that the depth types could use some explanation though.
|
that's from existing master, and wasn't my contribution. not related to this PR, tho perhaps you think this PR is a good place to fix this issue with master?
if you have another idea in mind to succinctly describe "we dont store qs depth in tt other than 0 and -1", im all ears.
this was cj's suggestion for standard QS behavior, again, if you have another idea im all ears. edit: ah, perhaps "stage" is more standard than "phase"? that's my bad
these werent in my original PR, and id be happy to delete them
perhaps "the absence of a value"?
tbh it's presently only -6 because it wasn't changed when the _RECAPTURES stage was removed, and since this PR is supposed to be focused on comments only i hadn't wanted to include that change here. should i? |
In addition to tweaks per comments, I've also made a further noticeable change to the DEPTH comments, since I'd just realized I was still missing half the interactions despite trying actively to document the interactions. (Good questions, Disservin, they got me to notice what I'd missed.) I've left separate commits for reviewing, but can easily squash at any time (e.g. when accepted) |
src/search.cpp
Outdated
@@ -1435,8 +1435,11 @@ Value Search::Worker::qsearch(Position& pos, Stack* ss, Value alpha, Value beta, | |||
|
|||
assert(0 <= ss->ply && ss->ply < MAX_PLY); | |||
|
|||
// Decide the replacement and cutoff priority of the qsearch TT entries | |||
ttDepth = ss->inCheck || depth >= DEPTH_QS_CHECKS ? DEPTH_QS_CHECKS : DEPTH_QS_NO_CHECKS; | |||
// Decide the replacement and cutoff priority of qsearch TT entries. Note that we don't |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps this is better.. I made the priority comment before a while
+ // ttDepth decides when to replace and when to TT cutoff for the qsearch TT entries.
- // Decide the replacement and cutoff priority of qsearch TT entries.
peregrine's most recent comment got my brain going once again, and ive now re-overhauled all the related comments. qs generals is at qs function, ttdepth comment doesn't mention the uses of ttdepth, and the DEPTH comments now reflect that these constants are infact only used for tt entries, which somehow i hadn't realized before today. i think the present form is considerably improved over the first version of the PR (and thus an even bigger improvement over master). I've also included a suggested renaming of would squashing be easier to review? |
35e5013
to
af90b90
Compare
I went ahead and squashed onto master. For the commit history that I've gone thru today to reach the present point see here: master...dubslow:Stockfish:qsDepthStagesTouchupOld |
Turns out they're only related to ttdepth, so some reorganization of related comment chunks is done as well. Rename the constants too. (Also "fix" movepicker to allow depths between CHECKS and NORMAL, which makes them easier to tweak, not that they get tweaked hardly ever. This was more beneficial when there was a third stage to DEPTH_QS, but it's still an improvement now) no functional change
af90b90
to
d603a0c
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
after the changes i think we can merge it
src/tt.cpp
Outdated
@@ -30,6 +30,9 @@ | |||
|
|||
namespace Stockfish { | |||
|
|||
// Per commit f7b3f0e, we use `bool(depth8)` to test if an entry is occupied. However we also need to |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i find linking to a specific commit a bit weird
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, on the other hand it does contain a lot more relevant detail. I thought best to keep comments short but leave a pointer to more should the reader be interested...
do you have alternatives in mind? not sure how best to do this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
mh okay just had a look at the pr and it seems it had a bit more detail than the avg one so can stay, just dont want all comments to be cluttered with "got introduced with xyz"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
perhaps it should say "per the details in commit f7b3f0e"?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
though what is the comment doing at the save function ? it aint being tested there only in the probe, where the meaning is kinda self explanatory found = bool(tte[i].depth8)
could point to the commit there
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
well i put the comment where we make heaviest use of DEPTH_ENTRY_OFFSET, since the comment is ultimately about that constant and why it exists. im happy to move it where you like
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On further thought, based on your comments here, I reviewed the old commit and concluded that more of its message should have been code-comments to begin with, so added those and removed the direct reference to the commit.
Is the resulting comment sufficiently short?
Thanks to all the comments, every single comment resulted in some improvement. |
Also "fix" movepicker to allow depths between CHECKS and NO_CHECKS, which makes them easier to tweak (not that they get tweaked hardly ever) (This was more beneficial when there was a third stage to DEPTH_QS, but it's still an improvement now)
no functional change