I have found that in one game, my program locked up when it reaches depth = 11 in the iterative search.
If I change the first block of code to the second block it then works ???
But the code gives the same logic/conditions ???
(I'm using Free Pascal).
Have I missed something ?
(the indenting has been mangled by 'talkchess' Doh !)
This code fails:
{----- now try a null move looking for a cutoff and an early exit -----}
IF NullAllowed AND
NOT Check AND {-- you cant pass when in check }
NOT OnlyPawns(Wtm) AND {-- risk zugswag....it will be rare }
(Depth > 2) THEN
BEGIN
SwapSides;
Score := -Search(-Beta, -Beta + 1, Depth - 2, False); {-- shallow null window search }
SwapSides; {-- we only want to know if its > Beta }
IF (Score >= Beta) THEN {-- we beat beta so we wont be going down this line }
BEGIN
Inc(BetaCuts);
Inc(NullCuts);
AddToTT(Data[Ply].ZorbistKey, Score, FailHigh, Depth, 'NULL');
Exit(Beta);
END;
END;
This code works:
{----- now try a null move looking for a cutoff and an early exit -----}
IF NullAllowed AND
NOT Check AND {-- you cant pass when in check }
NOT OnlyPawns(Wtm) THEN {-- risk zugswag....it will be rare }
BEGIN
IF Depth > 2 THEN
BEGIN
SwapSides;
Score := -Search(-Beta, -Beta + 1, Depth - 2, False); {-- shallow null window search }
SwapSides; {-- we only want to know if its > Beta }
IF (Score >= Beta) THEN {-- we beat beta so we wont be going down this line }
BEGIN
Inc(BetaCuts);
Inc(NullCuts);
AddToTT(Data[Ply].ZorbistKey, Score, FailHigh, Depth, 'NULL');
Exit(Beta);
END;
END;
END;
This is strange ?
Moderators: hgm, Rebel, chrisw
-
- Posts: 334
- Joined: Sat Feb 25, 2012 10:42 pm
- Location: Stockholm
Re: This is strange ?
Hi Lauriet!lauriet wrote: ↑Tue May 26, 2020 5:00 am I have found that in one game, my program locked up when it reaches depth = 11 in the iterative search.
If I change the first block of code to the second block it then works ???
But the code gives the same logic/conditions ???
(I'm using Free Pascal).
Have I missed something ?
(the indenting has been mangled by 'talkchess' Doh !)
This code fails:
{----- now try a null move looking for a cutoff and an early exit -----}
IF NullAllowed AND
NOT Check AND {-- you cant pass when in check }
NOT OnlyPawns(Wtm) AND {-- risk zugswag....it will be rare }
(Depth > 2) THEN
BEGIN
SwapSides;
Score := -Search(-Beta, -Beta + 1, Depth - 2, False); {-- shallow null window search }
SwapSides; {-- we only want to know if its > Beta }
IF (Score >= Beta) THEN {-- we beat beta so we wont be going down this line }
BEGIN
Inc(BetaCuts);
Inc(NullCuts);
AddToTT(Data[Ply].ZorbistKey, Score, FailHigh, Depth, 'NULL');
Exit(Beta);
END;
END;
This code works:
{----- now try a null move looking for a cutoff and an early exit -----}
IF NullAllowed AND
NOT Check AND {-- you cant pass when in check }
NOT OnlyPawns(Wtm) THEN {-- risk zugswag....it will be rare }
BEGIN
IF Depth > 2 THEN
BEGIN
SwapSides;
Score := -Search(-Beta, -Beta + 1, Depth - 2, False); {-- shallow null window search }
SwapSides; {-- we only want to know if its > Beta }
IF (Score >= Beta) THEN {-- we beat beta so we wont be going down this line }
BEGIN
Inc(BetaCuts);
Inc(NullCuts);
AddToTT(Data[Ply].ZorbistKey, Score, FailHigh, Depth, 'NULL');
Exit(Beta);
END;
END;
END;
In Free Pascal the order of evaluating expressions might not be in the order you have written the expressions (the optimiser might decide differently). See https://www.freepascal.org/docs-html/ref/refch12.html. I guess one (or more) of your Boolean functions/properties has a side effect or throws an exception but in the second code block you got lucky and the optimiser changed the execution order and the problematic function was not called.
/Pio
-
- Posts: 349
- Joined: Sat Aug 06, 2016 8:31 pm
- Location: United States
Re: This is strange ?
To maintain formatting, etc., you can use a code block:
Code: Select all
no indent
two space indent
four space indent
tab indent
Erin Dame
Author of RookieMonster
Author of RookieMonster
-
- Posts: 1564
- Joined: Thu Jul 16, 2009 10:47 am
- Location: Almere, The Netherlands
Re: This is strange ?
These are bugs in Free Pascal.
I maintain a Pascal version of my engine too and noticed several times that Free-Pascal has not the quality like most C compilers have.
On several occasions I had quirks like this, usually I could fix them the same way you did by using an additional begin-end block.
Currently I use Lazarus 2.1 with Free Pascal 3.3.1 (64 bit), this gives me the least headache.
I maintain a Pascal version of my engine too and noticed several times that Free-Pascal has not the quality like most C compilers have.
On several occasions I had quirks like this, usually I could fix them the same way you did by using an additional begin-end block.
Currently I use Lazarus 2.1 with Free Pascal 3.3.1 (64 bit), this gives me the least headache.