Problem with the TT

Discussion of chess software programming and technical issues.

Moderator: Ras

User avatar
Kempelen
Posts: 620
Joined: Fri Feb 08, 2008 10:44 am
Location: Madrid - Spain

Problem with the TT

Post by Kempelen »

I am having a problem with the TT, and I think is about hashing "non-perfect" qsearch scores, I mean, those nodes evaluated at qsearch with no-check detection. Let see.

The position is this:
1r4k1/5ppp/2Q5/2p1qP2/6n1/3Br1P1/2P4P/RR4K1 b - - 0 27

This is the sequence of commands and output with TT enabled:

Code: Select all

st 5
go
ply score   time     nodes  pv
--- ----- ------ --------- -------------------------------------------------
 1    113     45      1762  1. ... Rb4 2. Rxb4 cxb4
 2   -M04     45      2062  1. ... Rb4 2. Ra8+ Qb8 3. Rxb8+ Rxb8 4. Rxb8+ Re8 5. Rxe8#
 2   -288     46      2186  1. ... Rxg3+ 2. hxg3 Qxg3+ 3. Kh1
 2   -154     46      2688  1. ... Rxd3 2. Rxb8+ Qxb8 3. cxd3
 2    -82     46      2931  1. ... Nxh2 2. Rxb8+ Qxb8 3. Kxh2 Qxg3+ 4. Kh1
 2    108     47      3220  1. ... Rxb1+ 2. Rxb1 Re1+ 3. Rxe1 Qxe1+ 4. Kg2
 3    108     48      3900  1. ... Rxb1+ 2. Rxb1 Re1+ 3. Rxe1 Qxe1+ 4. Kg2
 4    136     53     10385  1. ... Rxb1+ 2. Rxb1 Re1+ 3. Rxe1 Qxe1+ 4. Kg2 Qf2+ 5. Kh3 Nxh2
 5     58     81     59579  1. ... Rxb1+ 2. Rxb1 Qd4 3. Kg2 Qd8 4. Qxc5
 5    143    119    134289  1. ... Qd4 2. Rxb8+ Re8+ 3. Kg2 Ne3+ 4. Kf3 Rxb8 5. Ra7
 6    115    130    157922  1. ... Qd4 2. Rxb8+ Re8+ 3. Kg2 Ne3+ 4. Kf3 Rxb8 5. Ra8 Rf8
 7     55    289    504507  1. ... Qd4 2. Rxb8+ Re8+ 3. Kg2 Ne3+ 4. Kf3 Rxb8 5. Re1 c4 6. Rxe3 cxd3 7. Rxd3
move Qd4
Rxb8
ply score   time     nodes  pv
--- ----- ------ --------- -------------------------------------------------
 1    142     20        41  2. ... Re8+ 3. Kg2 Rxb8 4. Ra8 Rf8 5. Rxf8+ Kxf8 6. Qa8+
 2     55     21        44  2. ... Re8+ 3. Kg2 Ne3+ 4. Kf3 Rxb8 5. Re1 c4 6. Rxe3 cxd3
 3     55     22        48  2. ... Re8+ 3. Kg2 Ne3+ 4. Kf3 Rxb8 5. Re1 c4 6. Rxe3 cxd3
 4     55     22        52  2. ... Re8+ 3. Kg2 Ne3+ 4. Kf3 Rxb8 5. Re1 c4 6. Rxe3 cxd3
 5     55     23        56  2. ... Re8+ 3. Kg2 Ne3+ 4. Kf3 Rxb8 5. Re1 c4 6. Rxe3 cxd3
 6     55     23        60  2. ... Re8+ 3. Kg2 Ne3+ 4. Kf3 Rxb8 5. Re1 c4 6. Rxe3 cxd3
 7     55     24        64  2. ... Re8+ 3. Kg2 Ne3+ 4. Kf3 Rxb8 5. Re1 c4 6. Rxe3 cxd3
 8   -M02     35     33833  2. ... Qd8?? 3. Rxd8+ Re8 4. Rxe8#
move Qd8
If I play the same position with TT disabled, I get the following:

Code: Select all

st 5
go
ply score   time     nodes  pv
--- ----- ------ --------- -------------------------------------------------
 1    113      1      1762  1. ... Rb4 2. Rxb4 cxb4
 2   -M04      1      2097  1. ... Rb4 2. Ra8+ Qb8 3. Rxb8+ Rxb8 4. Rxb8+ Re8 5. Rxe8#
 2   -288      2      2221  1. ... Rxg3+ 2. hxg3 Qxg3+ 3. Kh1
 2   -154      2      2727  1. ... Rxd3 2. Rxb8+ Qxb8 3. cxd3
 2    -82      2      3025  1. ... Nxh2 2. Rxb8+ Qxb8 3. Kxh2 Qxg3+ 4. Kh1
 2    108      3      3377  1. ... Rxb1+ 2. Rxb1 Re1+ 3. Rxe1 Qxe1+ 4. Kg2
 3    108      4      4124  1. ... Rxb1+ 2. Rxb1 Re1+ 3. Rxe1 Qxe1+ 4. Kg2
 4    136      7     12252  1. ... Rxb1+ 2. Rxb1 Re1+ 3. Rxe1 Qxe1+ 4. Kg2 Qf2+ 5. Kh3 Nxh2
 5     58     34     85903  1. ... Rxb1+ 2. Rxb1 Qd4 3. Kg2 Qd8 4. Qxc5
 5    143     67    184468  1. ... Qd4 2. Rxb8+ Re8+ 3. Kg2 Ne3+ 4. Kf3 Rxb8 5. Ra7
 6    115     84    221914  1. ... Qd4 2. Rxb8+ Re8+ 3. Kg2 Ne3+ 4. Kf3 Rxb8 5. Ra8 Rf8
 7    115    557   1175379  1. ... Qd4 2. Rxb8+ Re8+ 3. Kg2 Ne3+ 4. Kf3 Rxb8 5. Ra8 Rf8
move Qd4
Rxb8
ply score   time     nodes  pv
--- ----- ------ --------- -------------------------------------------------
 1    142      0        87  2. ... Re8+ 3. Kg2 Rxb8
 2    142      0       107  2. ... Re8+ 3. Kg2 Rxb8
 3    157      1       250  2. ... Re8+ 3. Kg2 Ne3+ 4. Kf2 Rxb8
 4    177      1       969  2. ... Re8+ 3. Kg2 Ne3+ 4. Kf3 Rxb8
 5    143      5      3405  2. ... Re8+ 3. Kg2 Ne3+ 4. Kf3 Rxb8 5. Ra7
 6    115     31     40074  2. ... Re8+ 3. Kg2 Ne3+ 4. Kf3 Rxb8 5. Ra8 Rf8
 7     46    175    295442  2. ... Re8+ 3. Kg2 Ne3+ 4. Kf3 Qg4+ 5. Kf2 Rxb8 6. Ra8 Nd1+ 7. Kg1 Rxa8 8. Qxa8#
 8     27    355    626849  2. ... Re8+ 3. Kg2 Rxb8 4. Ra8 Qd8 5. Rxb8 Qxb8 6. Qxc5 Qb7+ 7. Kg1 Qb1+ 8. Bf1
 9     27    537    907597  2. ... Re8+ 3. Kg2 Rxb8 4. Ra8 Qd8 5. Rxb8 Qxb8 6. Qxc5 Qb7+ 7. Kg1 Qb1+ 8. Bf1
move Re8+
As you can see, comparing first and second, the TT disabled version plays the good move.
Any cloud of what could be the problem?

I think maybe is about mate score in qsearch. As you can see in the last output for 7 depth, the line is a 46 score, where the true is that it is a mate. This is because my qsearch function dont generate at all moves for check. My qsearch routine only generate checks in the qsearch for the first plys and there is a limit in qnodes too. Well, I think the problem is because that, not sure....

This lead me to think what is the proper way to store exact values in hash table when the search is from a non-check qsearch. any ideas?
mambofish

Re: Problem with the TT

Post by mambofish »

Hi Fermin

I'm not sure what the exact problem is, but you seem to have issues even with TT turned off. Re8 is the "correct" first move, but its not a check, as your PV indicates, unless you are checking your own king?

Also there is no way the black queen can go from e5 to d1! Is the FEN position you gave correct? Perhaps the board/colours are the wrong way round?
User avatar
Kempelen
Posts: 620
Joined: Fri Feb 08, 2008 10:44 am
Location: Madrid - Spain

Re: Problem with the TT

Post by Kempelen »

Code: Select all

I'm not sure what the exact problem is, but you seem to have issues even with TT turned off. Re8 is the "correct" first move, but its not a check, as your PV indicates, unless you are checking your own king? 
You are wrong. FEN is correct. This is a position with a discovered check. After Qd4, Rxb8+, Re8 is check. Q in d4 in checking king in g1.

Code: Select all

Also there is no way the black queen can go from e5 to d1! 

where have you seen this?
User avatar
Kempelen
Posts: 620
Joined: Fri Feb 08, 2008 10:44 am
Location: Madrid - Spain

Re: Problem with the TT

Post by Kempelen »

Forget!!. I found the problem. It was not a TT issue, but a root move order fault. Hard bug......
mambofish

Re: Problem with the TT

Post by mambofish »

I think I must have pasted the position wrongly, in some way! :oops:

Glad you found the problem anyway!