perpetual check position

Discussion of chess software programming and technical issues.

Moderators: hgm, Rebel, chrisw

User avatar
Evert
Posts: 2929
Joined: Sat Jan 22, 2011 12:42 am
Location: NL

Re: perpetual check position

Post by Evert »

Analysis by Jazz:

Code: Select all

  1 -1620     0        17 1. Rh2  
  2 -1665     0       205 1. Rg2 Kh5 2. Rg4 
  3 -1660     1      1890 1. Re5 Kg6 2. Re6 Kh7 3. Rg2 
  4 -1686     3      4925 1. Re5 Kg6 2. Re6 Kh7 3. Rh2 Kg8 4. Re8 Kf7 
  5 -1673     4      9274 1. Re5 Kg6 2. Re6 Kh7 3. Rh2 Kg7 4. Rh6 Nd7 
  6 -1673     8     19861 1. Re5 Kg6 2. Re6 Kf7 3. Re7 Kf8 4. Re8 Kg7 5. Re7 Kh8 6. Rh2 Kg8 7. Re8 
  7 -1674    16     44435 1. Re5 Kg6 2. Re6 Kf7 3. Re7 Kf8 4. Re8 Kg7 5. Re7 Kh8 6. Rh2 Kg8 7. Re8 Kf7 8. Rc8 
  8 -1657    32     96053 1. Re5 Kg6 2. Re6 Kf7 3. Re7 Kf8 4. Re8 Kg7 5. Re7 Kh8 6. Re8 Kh7 7. Re7 Kh6 8. Rh2 Kg5 
  9 -1626    55    197657 1. Re5 Kg6 2. Re6 Kf7 3. Re7 Kf8 4. Re8 Kg7 5. Re7 Kh6 6. Re6 Kh5 7. Re5 Kh4 8. Re4 Kh3 9. Rh6 Kg2 
 10 -1628   105    441834 1. Re5 Kg6 2. Re6 Kf7 3. Re7 Kf8 4. Re8 Kg7 5. Re7 Kh6 6. Re6 Kh5 7. Re5 Kh4 8. Re4 Kh3 9. Rh6 Kg2 10. Rc4 
 11 -1610   222   1013318 1. Re5 Kg6 2. Re6 Kf7 3. Re7 Kf8 4. Re8 Kg7 5. Re7 Kh6 6. Re6 Kh5 7. Re5 Kg4 8. Re4 Kf5 9. Re5 Kf4 10. Re4 Kf3 11. Re3 Kg4 
 12 -1631   490   2276894 1. Re5 Kg6 2. Re6 Kf7 3. Re7 Kf8 4. Re8 Kg7 5. Re7 Kh6 6. Re6 Kh7 7. Re7 
 13 -1654  1829   7932680 1. Re5 Kg6 2. Re6 Kg7 3. Re7 Kf8 
 14    0  2490  11063648 1. Re5 Kg6 2. Re6 Kg7 3. Re7 Kh8 4. Re8 Kh7 5. Re7 Kh8 
JVMerlino
Posts: 1357
Joined: Wed Mar 08, 2006 10:15 pm
Location: San Francisco, California

Re: perpetual check position

Post by JVMerlino »

If you want some other test positions that are more for the strength range of your engine, try:

http://computer-chess.org/doku.php?id=c ... tpositions

There is one position (an avoid move) that primarily tests draw recognition.

jm
User avatar
stegemma
Posts: 859
Joined: Mon Aug 10, 2009 10:05 pm
Location: Italy
Full name: Stefano Gemma

Re: perpetual check position

Post by stegemma »

ymatioun wrote:I just searched this position with Fizbo to depth 39/seldepth 67, and it still does not see a draw.

It looks to me that the depth for a forced repetition draw here s really very high (black king can go on most squares in files f-g-h twice before it happens).

I don't have any special logic to recognize perpetual check, so i would not expect Fizbo to see it.

Does anybody use special logic for these positions?

Thanks.
I use two kind of test:

- I store the already played positions of the game in the hash, with a flag TT_DRAW; when I find one of those positions during search, I return 0 (or a little less)
- I check actual position hash with the one of two plyes before; this signal forth/back couple of moves

I still miss repetition of multiple moves in the search.
Author of Drago, Raffaela, Freccia, Satana, Sabrina.
http://www.linformatica.com
User avatar
cdani
Posts: 2204
Joined: Sat Jan 18, 2014 10:24 am
Location: Andorra

Re: perpetual check position

Post by cdani »

Andscacs sees 0 at depth 12 with seldepth 36, the same maximum theorical depth that Karlo Bala told, but I doubt is related to this limit.

I have not implemented any special rule to detect such positions. Is consequence simply of the normal search, which detects repetitions as draw. It prunes/reduces as always, and in the lines that it searches it does not find a way for the black king to scape the checks.

So if a position had some strange resource to scape the perpetual, maybe Andscacs will not see it and will think that is 0 while maybe it was lost. As always is a statistical tradeoff when deciding what goes inside the engine.

Code: Select all

Andscacs 0.87117 by Daniel Jose
pf qn6/qn6/pp6/6k1/4R3/8/4R3/K7 w - - 0 1
20
info depth 1 currmove e2e1 currmovenumber 1
info depth 1 seldepth 1 score cp -1092 nodes 30 nps 15000 time 2 pv e2f2
info depth 2 seldepth 4 score cp -1290 nodes 127 nps 21166 time 6 pv e2f2 g5h5
info depth 2 seldepth 4 score cp -1108 nodes 148 nps 16444 time 9 pv e2g2 g5h5
info depth 3 seldepth 6 score cp -1097 nodes 252 nps 19384 time 13 pv e2g2 g5h5
g2g7
info depth 4 seldepth 8 score cp -1236 nodes 385 nps 22647 time 17 pv e2g2 g5h5
g2g8 b7c5
info depth 5 currmove e2g2 currmovenumber 1
info depth 5 seldepth 8 score cp -1090 nodes 1153 nps 48041 time 24 pv e2g2 g5h5
 e4e7 b7c5 g2h2 h5g5
info depth 6 seldepth 10 score cp -1115 nodes 1705 nps 58793 time 29 pv e2g2 g5h
5 e4e7 h5h6 e7g7 b6b5
info depth 7 currmove e2g2 currmovenumber 1
info depth 7 seldepth 14 score cp -1080 nodes 3814 nps 105944 time 36 pv e2g2 g5
f6 g2f2 f6g6 e4e7 b7c5 e7a7 a8a7 f2g2 g6f6
info depth 8 seldepth 15 score cp -1088 nodes 9062 nps 197000 time 46 pv e4e5 g5
h4 e5e4 h4h5 e2h2 h5g6 h2g2 g6f5 e4e7 b7c5 g2f2 f5g5
info depth 9 currmove e4e5 currmovenumber 1
info depth 9 seldepth 19 score cp -1059 nodes 10240 nps 189629 time 54 pv e4e5 g
5h4 e5e4 h4h5 e2h2 h5g6 h2g2 g6f5 e4e7 b7c5 g2f2 f5g5 e7a7 a8a7 a1a2
info depth 9 currmove e4g4 currmovenumber 13
info depth 9 seldepth 17 score cp -1388 nodes 29405 nps 392066 time 75 pv e2g2 g
5f5 e4e7 b6b5 e7g7 f5e4 g7e7 e4d4 g2d2 d4c3 d2d1
info depth 9 seldepth 29 score cp -1102 nodes 34059 nps 400694 time 85 pv e4e5 g
5g6 e5e6 g6f7 e6e7 f7f8 e7e8 f8g7 e2e7 g7g6 e8g8 g6h6 g8g2 a6a5
info depth 10 seldepth 27 score cp -1077 nodes 37003 nps 393648 time 94 pv e4e5
g5g6 e5e6 g6f7 e6e7 f7f8 e7e8 f8g7 e8e7 g7f6 e2e6 f6g5 e6e5 g5h4 e5e4 h4h3 e7g7

info depth 11 seldepth 34 score cp -808 nodes 41920 nps 399238 time 105 pv e4e5
g5g6 e5e6 g6f7 e6e7 f7f8 e7e8 f8g7 e8e7 g7g8 e7e8 g8h7 e8e7 h7h6 e7e6 h6h5 e6e5
h5g4 e5e4 g4f5
info depth 12 currmove e4e5 currmovenumber 1
info depth 12 seldepth 36 score cp -1 nodes 46961 nps 401376 time 117 pv e4e5 g5
g6 e5e6 g6g7 e6e7 g7g8 e7e8 g8h7 e8e7 h7h8 e7e8 h8h7
zenpawn
Posts: 349
Joined: Sat Aug 06, 2016 8:31 pm
Location: United States

Re: perpetual check position

Post by zenpawn »

Thank you all for such a lively discussion, feedback, more test positions, and encouragement. You've definitely made me feel welcome. :)

Regarding check extensions, it basically accomplishes the same goal to include checks in qsearch, right?

-Erin
Sven
Posts: 4052
Joined: Thu May 15, 2008 9:57 pm
Location: Berlin, Germany
Full name: Sven Schüle

Re: perpetual check position

Post by Sven »

zenpawn wrote:Regarding check extensions, it basically accomplishes the same goal to include checks in qsearch, right?
Only partially. "Same goal" by improving tactical abilities, but that's a very general goal.

Check extension means that you extend replies to check slightly deeper, e.g. one ply. This can help to find forced variations that start with giving check.

Including checks in qsearch is a bit different, here you make the search wider by adding more moves to be searched (quiet checks), but you only do that during the first N plies of qsearch, typically N=1. This will basically extend the horizon at some leaf nodes. But the kind of extension is not the same as for check extension.
zenpawn
Posts: 349
Joined: Sat Aug 06, 2016 8:31 pm
Location: United States

Re: perpetual check position

Post by zenpawn »

Sven Schüle wrote: Including checks in qsearch is a bit different, here you make the search wider by adding more moves to be searched (quiet checks), but you only do that during the first N plies of qsearch, typically N=1. This will basically extend the horizon at some leaf nodes. But the kind of extension is not the same as for check extension.
Wider versus a qsearch without checks, sure, but if you don't limit checks to the first N-ply, then I don't see how it's not doing the same thing as check extensions.
User avatar
hgm
Posts: 27794
Joined: Fri Mar 10, 2006 10:06 am
Location: Amsterdam
Full name: H G Muller

Re: perpetual check position

Post by hgm »

Check extension would cause a brach that starts with a check in the root to be searched deeper than the other branches, even in the d=10 iteration. Searching checks in QS would not treat lines that started with a check any different from those that didn't. Only lines that have a check as the 11th ply.
Sven
Posts: 4052
Joined: Thu May 15, 2008 9:57 pm
Location: Berlin, Germany
Full name: Sven Schüle

Re: perpetual check position

Post by Sven »

zenpawn wrote:
Sven Schüle wrote: Including checks in qsearch is a bit different, here you make the search wider by adding more moves to be searched (quiet checks), but you only do that during the first N plies of qsearch, typically N=1. This will basically extend the horizon at some leaf nodes. But the kind of extension is not the same as for check extension.
Wider versus a qsearch without checks, sure, but if you don't limit checks to the first N-ply, then I don't see how it's not doing the same thing as check extensions.
In theory you would almost be right but that won't work in practice since it would result in an unmanageable tree explosion. It would search a much larger tree than with just check extension. The latter does not add checks and their subtrees, it just extends replies to checks which were already there.

Consider this example of a queens ending which could be reached one ply above the horizon of a full-width search:
[d]2q5/p5k1/1p1Q4/1Pp5/P1P5/8/4K3/8 w - - 0 1
The last ply of full-width search will probably include to search checks like 1.Qe5+ or 1.Qg3+. Check extension will ensure to search all check evasions for these instead of doing an immediate qsearch (which can be misleading when in check). After these replies you would start a regular qsearch, and there will be only very few captures to consider. However, adding checks in qsearch will change a lot here. White to move will have many more checks (which get check-extended as well), and you will see a heavy tree explosion if you do not limit checks in qsearch to some N. The white queen will try to give check where it can.
petero2
Posts: 688
Joined: Mon Apr 19, 2010 7:07 pm
Location: Sweden
Full name: Peter Osterlund

Re: perpetual check position

Post by petero2 »

zenpawn wrote:It was an example of perpetual check/three-fold repetition when white is to move, whereas if black moves first, he wins.

[d]qn6/qn6/pp6/6k1/4R3/8/4R3/K7 w - - 0 1

My question is what should be the minimum depth an engine needs to declare this a draw as white?
Texel finds it at depth 8 after 15 milliseconds:

Code: Select all

info depth 8 score cp 0 lowerbound time 15 nodes 42318 nps 2821200 pv e4e5 g5f4 e5e4 f4f5 e4e5 f5g4 e5e4 g4h5 e4e5 h5g6 e5e6 g6h7 e6e7 h7h6 e7e6 h6g7 e6e7 g7f8 e7e8 f8g7 e8e7
I am not sure this is a good thing though. It probably means that texel is doing too many extensions which likely hurts more than it helps on average. Texel uses both check extensions and singular extensions.