bug?

Discussion of chess software programming and technical issues.

Moderators: hgm, Rebel, chrisw

User avatar
hgm
Posts: 27808
Joined: Fri Mar 10, 2006 10:06 am
Location: Amsterdam
Full name: H G Muller

Re: bug?

Post by hgm »

flok wrote:The node with hash a1bd4ada44bfd5ea (r3k2r/p1p2p2/2n5/1p1Pp1pp/4P3/1QP1NPPb/R2B3P/4K2R b Kkq - 0 19) results in b5b4 with score -110.
"results in" as in "this was found to be the best move with that score after searching all moves", or were that move and score in the TT entry?
Now that node has no a tt with no move information with score -887.
Here you lost me. Which node? That after b5b4? But there white is to move, so I would expect the score to be white POV. So how can the score be -887? White is a Queen ahead,so I would expect +887.
That node calls seach for the first move, e160896154ae1a29 (r3k2r/p1p2p2/2n5/3Pp1pp/1p2P3/1QP1NPPb/R2B3P/4K2R w Kkq - 0 20).
Well, that is a reasonable score.
e160896154ae1a29 does a tt checkwith score 98 and move d5xc6 apparently not enough so it continous with a null move. The null move has hash 855974cabd799b3c and fen r3k2r/p1p2p2/2n5/3Pp1pp/1p2P3/1QP1NPPb/R2B3P/4K2R b Kkq - 0 20.
The FEN gives a position after Qxa2 Rxa2 b5b4 null. You search that null AFTER Qxa2 Rxa2 b5b4 d5xc6 ? (This is a bit unusual; normally one searches nullmove before hash move.) In any case it is strange that in the latter line with d5xc6 the score would be 98, as white is now a Queen + Knight ahead. So it must be a lower bound. But it is only what is in the TT. Didn't it get searched,and if so, what was the score from the search?
The null move results in b4xc3 with score -110 returned:

Code: Select all

b4xc3 33aae4f9c5e06aad returned with score -110 | d5c6/110/search 33aae4f9c5e06aad "r3k2r/p1p2p2/2n5/3Pp1pp/4P3/1Qp1NPPb/R2B3P/4K2R w Kkq - 0 21"
...
o-o a0df19aba732ae04 returned with score -110 | d5c6/110/search a0df19aba732ae04 "r4rk1/p1p2p2/2n5/3Pp1pp/1p2P3/1QP1NPPb/R2B3P/4K2R w K - 1 21"
We are talking about the line Qxa2 Rxa2 b5b4 null b4xc3 here? The -110 is indeed what ends up in the root. But the score from a null move should never be propagated to the root. You only use it when it is above beta, to make the current node fail high, meaning that in the parent the move leading to it fails low, and is rejected compared to the PV move.
flok

Re: bug?

Post by flok »

Code: Select all

855974cabd799b3c r3k2r/p1p2p2/2n5/3Pp1pp/1p2P3/1QP1NPPb/R2B3P/4K2R b Kkq - 0 20 starts with -110/-109, null move, returns b4xc3 with score -110
e160896154ae1a29 r3k2r/p1p2p2/2n5/3Pp1pp/1p2P3/1QP1NPPb/R2B3P/4K2R w Kkq - 0 20 starts with -10000/110 returns score 110
a1bd4ada44bfd5ea r3k2r/p1p2p2/2n5/1p1Pp1pp/4P3/1QP1NPPb/R2B3P/4K2R b Kkq - 0 19 starts with -110/10000, returns b5-b4 with -110
hgm wrote:
flok wrote:The node with hash a1bd4ada44bfd5ea (r3k2r/p1p2p2/2n5/1p1Pp1pp/4P3/1QP1NPPb/R2B3P/4K2R b Kkq - 0 19) results in b5b4 with score -110.
"results in" as in "this was found to be the best move with that score after searching all
moves", or were that move and score in the TT entry?
During the search of a branch for iteration depth 9, near the end of the branch a1bd4ada44bfd5ea appears. If a1bd4ada44bfd5ea has been searched fully, then it comes up with b5-b4 with a score of -110.

The first step of node a1bd4ada44bfd5ea is checking the tt. There it finds a tt-record with no move stored in it but with a score of -887.
Now that node has no a tt with no move information with score -887.
Here you lost me. Which node? That after b5b4? But there white is to move, so I would expect the score to be white POV. So how can the score be -887? White is a Queen ahead,so I would expect +887.
One of the child nodes of a1bd4ada44bfd5ea is e160896154ae1a29.
e160896154ae1a29 begins with a tt check which results in d5xc6 with a score of 98, no beta cut-off so it goes on: it goes on with null-move.

The null-move node has hash 855974cabd799b3c. The first move it finds is b4xc3 which has a score of -110. No moves with a higher score are found so that is returned to e160896154ae1a29.
e160896154ae1a29 has at that moment alpha -10000 and beta 110. The score returned by NM is - -110 so 110 and thus -110 is returned to a1bd4ada44bfd5ea
You search that null AFTER Qxa2 Rxa2 b5b4 d5xc6 ? (This is a bit unusual; normally one searches nullmove before hash move.)
Yes, I check null move after tt. What about checking before AND after the null move? TT check is cheaper than null move?
In any case it is strange that in the latter line with d5xc6 the score would be 98, as white is now a Queen + Knight ahead. So it must be a lower bound. But it is only what is in the TT. Didn't it get searched,and if so, what was the score from the search?

No d5xc6 was found in the tt but the tt score (98) did not cause a beta c/o so it continued with the node (and thus the null move).
The null move results in b4xc3 with score -110 returned:

Code: Select all

b4xc3 33aae4f9c5e06aad returned with score -110 | d5c6/110/search 33aae4f9c5e06aad "r3k2r/p1p2p2/2n5/3Pp1pp/4P3/1Qp1NPPb/R2B3P/4K2R w Kkq - 0 21"
...
o-o a0df19aba732ae04 returned with score -110 | d5c6/110/search a0df19aba732ae04 "r4rk1/p1p2p2/2n5/3Pp1pp/1p2P3/1QP1NPPb/R2B3P/4K2R w K - 1 21"
We are talking about the line Qxa2 Rxa2 b5b4 null b4xc3 here?
Yes, that b4xc3 is the result of the null move, with score -110 (which is 110 in the parent).
The -110 is indeed what ends up in the root. But the score from a null move should never be propagated to the root. You only use it when it is above beta,
Yes, it is above beta and so returned to the node above it.
to make the current node fail high, meaning that in the parent the move leading to it fails low, and is rejected compared to the PV move.
So the null move returns -110, the parent of the null move gets that as 110 (-search() ). alpha beta of the nm-parent is -10000/110 thus a beta-cutoff happens.
But then, the a1bd4ada44bfd5ea node has no move (branch) with a better score than that 110. Right?

I wonder if I did the null move wrong: a1bd4ada44bfd5ea is white (next move is b), e160896154ae1a29 is black (next move is w) so shouldn't the null move do a search for black too?
User avatar
hgm
Posts: 27808
Joined: Fri Mar 10, 2006 10:06 am
Location: Amsterdam
Full name: H G Muller

Re: bug?

Post by hgm »

OK, but if beta = 110, you must already have had a move that scored 110, and the branch you are looking at now should never have become PV. The cutoff occurred because it was found to be irrelevant as we already had something better. What was that something better?
flok

Re: bug?

Post by flok »

It looks like that is caused by the aspiration windowing:

Code: Select all

++++START 0 15f0b8764a43cf81 r3k2r/p1p2p2/2n5/qp1Pp1pp/4P3/1QP1NPPb/P2B3P/R3K2R b KQkq - 0 18 -10000/10000
info depth 1 seldepth 5 score cp 27 time 12 nodes 79 pv c6e7 15f0b8764a43cf81 "r3k2r/p1p2p2/2n5/qp1Pp1pp/4P3/1QP1NPPb/P2B3P/R3K2R b KQkq - 0 18" 
++++START 0 15f0b8764a43cf81 r3k2r/p1p2p2/2n5/qp1Pp1pp/4P3/1QP1NPPb/P2B3P/R3K2R b KQkq - 0 18 2/52
info depth 2 seldepth 8 score cp 2 time 20 nodes 213 pv a5a4 15f0b8764a43cf81 "r3k2r/p1p2p2/2n5/qp1Pp1pp/4P3/1QP1NPPb/P2B3P/R3K2R b KQkq - 0 18" 
++++START 0 15f0b8764a43cf81 r3k2r/p1p2p2/2n5/qp1Pp1pp/4P3/1QP1NPPb/P2B3P/R3K2R b KQkq - 0 18 -10000/52
info depth 2 seldepth 6 score cp 1 time 29 nodes 466 pv c6e7 15f0b8764a43cf81 "r3k2r/p1p2p2/2n5/qp1Pp1pp/4P3/1QP1NPPb/P2B3P/R3K2R b KQkq - 0 18" 
++++START 0 15f0b8764a43cf81 r3k2r/p1p2p2/2n5/qp1Pp1pp/4P3/1QP1NPPb/P2B3P/R3K2R b KQkq - 0 18 -24/26
info depth 3 seldepth 11 score cp 20 time 35 nodes 885 pv c6e7 15f0b8764a43cf81 "r3k2r/p1p2p2/2n5/qp1Pp1pp/4P3/1QP1NPPb/P2B3P/R3K2R b KQkq - 0 18" 
++++START 0 15f0b8764a43cf81 r3k2r/p1p2p2/2n5/qp1Pp1pp/4P3/1QP1NPPb/P2B3P/R3K2R b KQkq - 0 18 -5/45
info depth 4 seldepth 13 score cp -5 time 80 nodes 4466 pv a5c3 15f0b8764a43cf81 "r3k2r/p1p2p2/2n5/qp1Pp1pp/4P3/1QP1NPPb/P2B3P/R3K2R b KQkq - 0 18" 
++++START 0 15f0b8764a43cf81 r3k2r/p1p2p2/2n5/qp1Pp1pp/4P3/1QP1NPPb/P2B3P/R3K2R b KQkq - 0 18 -10000/45
info depth 4 seldepth 19 score cp -30 time 104 nodes 6586 pv c6e7 15f0b8764a43cf81 "r3k2r/p1p2p2/2n5/qp1Pp1pp/4P3/1QP1NPPb/P2B3P/R3K2R b KQkq - 0 18" 
++++START 0 15f0b8764a43cf81 r3k2r/p1p2p2/2n5/qp1Pp1pp/4P3/1QP1NPPb/P2B3P/R3K2R b KQkq - 0 18 -55/-5
info depth 5 seldepth 15 score cp -55 time 134 nodes 8998 pv a5a2 15f0b8764a43cf81 "r3k2r/p1p2p2/2n5/qp1Pp1pp/4P3/1QP1NPPb/P2B3P/R3K2R b KQkq - 0 18" 
++++START 0 15f0b8764a43cf81 r3k2r/p1p2p2/2n5/qp1Pp1pp/4P3/1QP1NPPb/P2B3P/R3K2R b KQkq - 0 18 -10000/-5
info depth 5 seldepth 20 score cp -98 time 174 nodes 12114 pv c6e7 15f0b8764a43cf81 "r3k2r/p1p2p2/2n5/qp1Pp1pp/4P3/1QP1NPPb/P2B3P/R3K2R b KQkq - 0 18" 
++++START 0 15f0b8764a43cf81 r3k2r/p1p2p2/2n5/qp1Pp1pp/4P3/1QP1NPPb/P2B3P/R3K2R b KQkq - 0 18 -123/-73
info depth 6 seldepth 18 score cp -123 time 354 nodes 26181 pv a7a6 15f0b8764a43cf81 "r3k2r/p1p2p2/2n5/qp1Pp1pp/4P3/1QP1NPPb/P2B3P/R3K2R b KQkq - 0 18" 
++++START 0 15f0b8764a43cf81 r3k2r/p1p2p2/2n5/qp1Pp1pp/4P3/1QP1NPPb/P2B3P/R3K2R b KQkq - 0 18 -10000/-73
info depth 6 seldepth 20 score cp -139 time 553 nodes 42838 pv c6e7 15f0b8764a43cf81 "r3k2r/p1p2p2/2n5/qp1Pp1pp/4P3/1QP1NPPb/P2B3P/R3K2R b KQkq - 0 18" 
++++START 0 15f0b8764a43cf81 r3k2r/p1p2p2/2n5/qp1Pp1pp/4P3/1QP1NPPb/P2B3P/R3K2R b KQkq - 0 18 -164/-114
info depth 7 seldepth 21 score cp -118 time 851 nodes 67557 pv c6e7 15f0b8764a43cf81 "r3k2r/p1p2p2/2n5/qp1Pp1pp/4P3/1QP1NPPb/P2B3P/R3K2R b KQkq - 0 18" 
++++START 0 15f0b8764a43cf81 r3k2r/p1p2p2/2n5/qp1Pp1pp/4P3/1QP1NPPb/P2B3P/R3K2R b KQkq - 0 18 -143/-93
info depth 8 seldepth 25 score cp -135 time 1604 nodes 128832 pv c6e7 15f0b8764a43cf81 "r3k2r/p1p2p2/2n5/qp1Pp1pp/4P3/1QP1NPPb/P2B3P/R3K2R b KQkq - 0 18" 
++++START 0 15f0b8764a43cf81 r3k2r/p1p2p2/2n5/qp1Pp1pp/4P3/1QP1NPPb/P2B3P/R3K2R b KQkq - 0 18 -160/-110
info depth 9 seldepth 27 score cp -110 time 2474 nodes 199764 pv c6e7 15f0b8764a43cf81 "r3k2r/p1p2p2/2n5/qp1Pp1pp/4P3/1QP1NPPb/P2B3P/R3K2R b KQkq - 0 18" 
++++START 0 15f0b8764a43cf81 r3k2r/p1p2p2/2n5/qp1Pp1pp/4P3/1QP1NPPb/P2B3P/R3K2R b KQkq - 0 18 -160/10000
info depth 9 seldepth 28 score cp -110 time 3507 nodes 287066 pv a5a2 15f0b8764a43cf81 "r3k2r/p1p2p2/2n5/qp1Pp1pp/4P3/1QP1NPPb/P2B3P/R3K2R b KQkq - 0 18"
+++START is emitted before the search starts and shows alpha/beta in the last column.
User avatar
hgm
Posts: 27808
Joined: Fri Mar 10, 2006 10:06 am
Location: Amsterdam
Full name: H G Muller

Re: bug?

Post by hgm »

So basically you say that the search failed low in the root because of aspiration there, but you played the move (which could thus be arbitrary poor, and indeed was) anyway.
flok

Re: bug?

Post by flok »

hgm wrote:So basically you say that the search failed low in the root because of aspiration there, but you played the move (which could thus be arbitrary poor, and indeed was) anyway.
Yes but:

Code: Select all

++++START 0 15f0b8764a43cf81 r3k2r/p1p2p2/2n5/qp1Pp1pp/4P3/1QP1NPPb/P2B3P/R3K2R b KQkq - 0 18 -160/-110 
info depth 9 seldepth 27 score cp -110 time 2474 nodes 199764 pv c6e7 15f0b8764a43cf81 "r3k2r/p1p2p2/2n5/qp1Pp1pp/4P3/1QP1NPPb/P2B3P/R3K2R b KQkq - 0 18" 
++++START 0 15f0b8764a43cf81 r3k2r/p1p2p2/2n5/qp1Pp1pp/4P3/1QP1NPPb/P2B3P/R3K2R b KQkq - 0 18 -160/10000 
info depth 9 seldepth 28 score cp -110 time 3507 nodes 287066 pv a5a2 15f0b8764a43cf81 "r3k2r/p1p2p2/2n5/qp1Pp1pp/4P3/1QP1NPPb/P2B3P/R3K2R b KQkq - 0 18"
At depth 9, initially the window was -160/-110 so the first time the aspiration-window was widened.
In the last iteration the windows is -160...10000 so the score of -110 fits in that?
User avatar
hgm
Posts: 27808
Joined: Fri Mar 10, 2006 10:06 am
Location: Amsterdam
Full name: H G Muller

Re: bug?

Post by hgm »

Ah, OK. So the question is where the -110 score comes from in that iteration. If after "Qxa2 Rxa2 b5b4 null" a score of 110 is enough to make white's null move fail high, black must already have had a move that scored -110 for him, either as an alternative for b5b4 or Qxa2. For otherwise beta would still be at 160, and a score of 110 would not be a fail high, so that the null move would be ignored.
Henk
Posts: 7220
Joined: Mon May 27, 2013 10:31 am

Re: bug?

Post by Henk »

Aspiration search never worked in my engine. For what to do if time is up and search is not finished. Giving awful bugs. Or you must handle search of a move in the root like a transaction or atomic operation.
User avatar
hgm
Posts: 27808
Joined: Fri Mar 10, 2006 10:06 am
Location: Amsterdam
Full name: H G Muller

Re: bug?

Post by hgm »

The problem that an interrupted search does not return a move is not unique to aspiration. The search of the PV move can also last unexpectedly long, especially after a ponder hit, where you might have gone to higher depth than you can affordjust because the opponent has been thinking long.

What I do is save the bestMove to a variable oldMove after every iteration. If bestMove is invalid after the search, I then play oldMove.
User avatar
Evert
Posts: 2929
Joined: Sat Jan 22, 2011 12:42 am
Location: NL

Re: bug?

Post by Evert »

hgm wrote:The problem that an interrupted search does not return a move is not unique to aspiration. The search of the PV move can also last unexpectedly long, especially after a ponder hit, where you might have gone to higher depth than you can affordjust because the opponent has been thinking long.

What I do is save the bestMove to a variable oldMove after every iteration. If bestMove is invalid after the search, I then play oldMove.
I only update the best move if the search found a move and it is better than my previous best move. Works well, unless you fail to complete the first iteration (which I've seen happen in SjaakII at short time controls in variants with large search trees).
In that case I simply play a random legal move (I'm probably screwed anyway, so what the heck).