mcostalba wrote:Eelco de Groot wrote:
Code: Select all
if (i < MultiPV)
{
if (Iteration <= 45)
{
Value gamma = Value(0x100);
if (Iteration >= 6) gamma = alpha;
value = -search(pos, ss, -gamma, newDepth + 1, 1, true, 0);
if (value > gamma && alpha <= gamma) alpha = Value((gamma + value) >> 1);
else alpha = Value((alpha + value - 0x300) >> 1);
}
Hi Eelco,
I think I cannot understund the above code. Care to explain me ?
Thanks
Marco
Hello Marco,
I don't think there is something mysterious going on
here, this was the easy part I thought

, it is just rather crude, a structure that allows me to try a few starting values for the aspiration window alpha, in case the alpha already provided by Joona's aspiration initialization is a bit too high, which would be a problem, or too low which does not really matter.
Alpha too low does not really matter all that much, why do I say that:
♠ Fruit searches with - Value Infite for alpha in the Root all the time and it is not really much slower than a finite but still relatively large window what I have tried.
♠

Then again, Stockfish is very fast so clearly Joona's aspiration windows contributes to speed!
♠

Also you can't use that - Value Infite for alpha for a nullwindow search so for this Joona's code provided an excellent starting point, a real aspiration alpha, to finally try this first part of the experiment, with a minimum of added overhead!
♠ Also, second reason, I did not really study Joona's code but figured it would not hurt to put in some checks on the aspiration windows. The nullwindow search is new here and can be used for this purpose but that is not the main reason for it: the main thought is, it is usually a lot faster doing a nullwindow search than doing a search_pv so you can search deeper, as long as your alpha is not too high.
♠ There are some drawbacks I suppose to doing this, but I don't have a clear picture about those. Otherwise -if there were no drawbacks at all- I think even a repeated nullwindow search here with "aspiration nullwindows" in case your alpha differs too much from value, would probably still allow you to search deeper than search_pv. As example of drawbacks, Null move (in the nullwindow search) could go wrong in case of Zugzwang but I suspect that is not the whole story.
♠ But even in this limited way you should at least be able to prime all the sidepaths of the PV, get a TTmove and search some of the sidepaths at least a bit deeper already - using NewDepth + 1 in the null window search, so with one ply deeper than the following standard search_pv. This NewDepth + 1 is actually conservative too but searching deeper has its drawbacks too, for instance the difference in NewDepth + x and NewDepth should not become too large.
♠ That I can adjust the alpha a bit this way with the returned result of the nullwindow is really not all that important, unless of course there would be a bug which in this case actually was true

The aspiration alpha in Multi-PV was too high for the rest of the moves.
♠ 45 is just a large number, using a constant alpha = 0x100 for the first 6 iterations is done just because Joona's aspirations only start at plydepths > 6.
♠ In case of a Fail Low in the first nullwindow search, alpha was obviously too high and should be lowered. Lowering to weighted average minus three pawns /2 : Value((alpha + value - 0x300) >> 1); appears to be still functional in the Multi-PV search that was actually broken, at least in a position like Ernest provided, I get at higher depths:
[d]rnbqkbn1/pppppppp/8/8/8/r7/P1PPPPPP/R1BQKBNR w KQq -
Engine: Ancalagon 1.3 WS150 Build 21 (256 MB)
by T. Romstad, M.Costalba, J. Kiiski, E. de Groot
20 39:22 +0.60 1.Bxa3 e5 2.Bb2 d6 3.e3 Qh4 4.Be2 Qa4
5.Nf3 Bf5 6.Bd3 Bxd3 7.cxd3 Qxd1+
8.Rxd1 Nc6 9.Rb1 Nf6 10.Ke2 Be7
11.Bc3 O-O-O 12.Rhc1 (1.158.136.286) 490
20 39:22 -1.27 1.Bb2 Ra4 (1.158.136.286) 490
20 39:22 -3.15 1.Nf3 Ra5 (1.158.136.286) 490
20 39:22 -4.90 1.e3 Ra5 2.Nf3 Nc6 3.d4 Nf6 4.Be2 e5
5.O-O exd4 6.exd4 Ne4 7.Bd3 d5 8.Qe2 Bf5
9.c4 Nb4 10.Bxe4 Bxe4 (1.158.136.286) 490
20 39:22 -4.96 1.d4 Ra5 2.e3 c5 3.Nf3 Nf6 4.Bd3 d5
5.c4 Qc7 6.Bd2 cxd4 7.Bxa5 Qxa5+
8.Qd2 Qxd2+ 9.Kxd2 dxe3+ 10.fxe3 dxc4
11.Bxc4 Nc6 12.Rad1 Ne4+ 13.Kc2 (1.158.136.286) 490
20 39:22 -5.13 1.f4 (1.158.136.286) 490
To be a bit more on the safe side I think you could subtract something like 0x300 + i * 0x50, where i is the number of Multi-PV lines, instead of just three pawns (3 * 0x100) but I don't know if it matters much. Not dividing 0x300 by two is probably the easiest way to be a bit safer in the existing code. In case the moves go quickly towards a lost position or mate, possibly then you can get bad results with my version in Multi_PV mode.
That is basically it, well at least that is how I interpret my own code
Eelco