From: Lucas Braesch Date: Mon, 3 Feb 2014 01:41:32 +0000 (+0800) Subject: Better document razoring X-Git-Url: https://git.sesse.net/?p=stockfish;a=commitdiff_plain;h=e88ef801af3ac5400c1b82d009666fb082c24a16 Better document razoring Use ralpha instead of rbeta * rbeta is confusing people. It took THREE attempts to code razoring at PV nodes correctly in a recent test, because of the rbeta trick. Unnecessary tricks should be avoided. * The more correct and self-documenting way of doing this, is to say that we use a zero window around alpha-margin, not beta-margin. The fact that, because we only do it at PV nodes, alpha happens to be beta-1 and that the current stuff with rbeta works, may be correct, but is confusing. Remove the misleading and partially erroneous comment about returning v + margin: * comments should explain what the code does, not what it could have done. * this comment is partially wrong in saying that v+margin is "logical", and that it is "surprising" that is doesn't work. From a theoretical perspective, at least 3 ways of doing this are equally defendable: 1/ fail hard: return alpha: The most conservative. We bet that the search will fail low, but we don't know by how much and don't want to take risks. 2/ aggressive fail soft: return v (what the current code does). This corresponds to normal fail soft, with the added assumption that we don't care about the reduction effect (see below point 3/) 3/ conservative fail soft: return v + margin. If the reduced search (qsearch) gives us a score <= v, we bet that the non reduced search will give us a score <= v + margin. * Saying that 2/ is "logical" implies that 1/ and 3/ are not, which is arguably wrong. Besides, experimental results tell us that 2/ beats 3/, and that's not something we can argue against: experimental results are the only trusted metric. * Also, with the benefit of hindsight, I don't think the fact that 2/ is better than 3/ is surprising at all. The point is that it is YOUR turn to move, and you are assuming that by NOT playing (and letting the opponent capture your hanging pieces in QS) you cannot generally GAIN razor_margin(depth). No functional change. --- diff --git a/src/search.cpp b/src/search.cpp index 0ee25bca..056dc250 100644 --- a/src/search.cpp +++ b/src/search.cpp @@ -600,11 +600,9 @@ namespace { && abs(beta) < VALUE_MATE_IN_MAX_PLY && !pos.pawn_on_7th(pos.side_to_move())) { - Value rbeta = beta - razor_margin(depth); - Value v = qsearch(pos, ss, rbeta-1, rbeta, DEPTH_ZERO); - if (v < rbeta) - // Logically we should return (v + razor_margin(depth)), but - // surprisingly this performed slightly weaker in tests. + Value ralpha = alpha - razor_margin(depth); + Value v = qsearch(pos, ss, ralpha, ralpha+1, DEPTH_ZERO); + if (v <= ralpha) return v; }