static mate/stalemate detection?

Discussion of chess software programming and technical issues.

Moderators: hgm, Harvey Williamson, bob

Forum rules
This textbox is used to restore diagrams posted with the [d] tag before the upgrade.
Post Reply
brtzsnr
Posts: 433
Joined: Fri Jan 16, 2015 3:02 pm
Contact:

static mate/stalemate detection?

Post by brtzsnr » Sat Nov 21, 2015 8:43 pm

Does your engine detect stalemates/mates in the evaluation?

For example, zurichess for

[d] 8/8/8/8/7p/1P5p/7p/2Q2K1k b - - 0 11

says

Code: Select all

info depth 0 seldepth 0 score cp -705 nodes 2 time 0 nps 29835 pv
info depth 1 seldepth 0 score cp 0 nodes 3 time 0 nps 33204 pv
info depth 2 seldepth 0 score cp 0 nodes 4 time 0 nps 41210 pv
info depth 3 seldepth 0 score cp 0 nodes 5 time 0 nps 47778 pv
info depth 4 seldepth 0 score cp 0 nodes 6 time 0 nps 54364 pv
info depth 5 seldepth 0 score cp 0 nodes 7 time 0 nps 59142 pv
info depth 6 seldepth 0 score cp 0 nodes 8 time 0 nps 64675 pv
This causes the engine to misbehave on this position from https://chessprogramming.wikispaces.com ... -Positions

[d] 8/8/p1p5/1p5p/1P5p/8/PPP2K1p/4R1rk w - - 0 1

Code: Select all

info depth 0 seldepth 0 score cp -292 nodes 4 time 0 nps 105716 pv
info depth 1 seldepth 3 score cp -303 nodes 71 time 0 nps 432302 pv e1e8
info depth 2 seldepth 3 score cp -336 nodes 348 time 0 nps 709937 pv e1f1 g1f1 f2f1
info depth 3 seldepth 3 score cp -316 nodes 908 time 1 nps 884365 pv e1e2 h4h3 e2e8
info depth 4 seldepth 5 score cp -331 nodes 1560 time 1 nps 915763 pv e1e2 h4h3 f2f3 g1g8
info depth 5 seldepth 7 score cp -337 nodes 4851 time 4 nps 991455 pv e1f1 h4h3 a2a3 g1f1 f2f1
info depth 6 seldepth 7 score cp -283 nodes 13756 time 11 nps 1162173 pv e1e6 g1b1 e6c6 b1b2 a2a3 h4h3
info depth 7 seldepth 10 score cp -334 nodes 52806 time 37 nps 1390196 pv e1f1 h4h3 a2a3 h5h4 c2c3 g1f1 f2f1
info depth 8 seldepth 10 score cp -171 nodes 57118 time 40 nps 1425271 pv e1f1 h4h3 a2a3 g1f1 f2f1 c6c5 b4c5 a6a5
info depth 9 seldepth 11 score cp -156 nodes 65090 time 43 nps 1481979 pv e1f1 h4h3 a2a3 h5h4 c2c3 c6c5 b4c5 g1f1 f2f1
info depth 10 seldepth 11 score cp -167 nodes 85665 time 53 nps 1613496 pv e1f1 h4h3 a2a3 h5h4 b2b3 g1f1 f2f1 c6c5 b4c5 a6a5
info depth 11 seldepth 11 score cp -106 nodes 128877 time 70 nps 1824630 pv e1f1 h4h3 a2a3 h5h4 b2b3 g1f1 f2f1 c6c5 b4c5 a6a5 c5c6
info depth 12 seldepth 12 score cp -119 nodes 218056 time 102 nps 2119484 pv e1f1 h4h3 a2a3 h5h4 b2b3 g1f1 f2f1 c6c5 b4c5 a6a5 c5c6 a5a4
info depth 13 seldepth 13 score cp -80 nodes 357895 time 149 nps 2389137 pv e1f1 h4h3 a2a3 h5h4 c2c3 c6c5 b4c5 g1f1 f2f1 a6a5 c5c6 a5a4 c6c7
info depth 14 seldepth 16 score cp 158 nodes 475138 time 191 nps 2480046 pv e1f1 h4h3 a2a3 g1f1 f2f1 c6c5 b4c5 b5b4 a3b4 a6a5 b4a5 h5h4 f1e2 h1g2
info depth 15 seldepth 16 score cp 152 nodes 643645 time 241 nps 2661368 pv e1f1 h4h3 a2a3 g1f1 f2f1 h5h4 f1f2 c6c5 b4c5 b5b4 a3b4 a6a5 b4b5 a5a4 c5c6
info depth 16 seldepth 16 score cp 0 nodes 906650 time 318 nps 2843906 pv e1f1 h4h3 a2a3 h5h4 b2b3 c6c5 b4c5 b5b4 a3b4 a6a5 b4b5 a5a4 b3a4 g1f1 f2f1
info depth 17 seldepth 17 score cp 17 nodes 1016184 time 354 nps 2864754 pv e1f1 h4h3 a2a3 h5h4 b2b3 c6c5 b4c5 b5b4 a3b4 a6a5 b4b5 a5a4 c5c6 a4a3 c6c7 g1f1 f2f1
info depth 18 seldepth 18 score cp 0 nodes 1228769 time 422 nps 2905172 pv e1f1 h4h3 a2a3 h5h4 b2b3 c6c5 b4c5 b5b4 a3b4 a6a5 b4b5 a5a4 c5c6 g1f1 f2f1 a4b3 c2b3
info depth 19 seldepth 18 score cp 0 nodes 1463242 time 498 nps 2934193 pv e1f1 h4h3 a2a3 h5h4 b2b3 c6c5 b4c5 b5b4 a3b4 a6a5 b4b5 a5a4 c5c6 g1f1 f2f1 a4b3 c2b3
info depth 20 seldepth 20 score cp 0 nodes 1788278 time 606 nps 2949757 pv e1f1 h4h3 a2a3 h5h4 b2b3 c6c5 b4c5 b5b4 a3b4 a6a5 b4b5 a5a4 b3a4 g1f1 f2f1
info depth 21 seldepth 21 score cp 705 nodes 2478368 time 854 nps 2900241 pv e1f1 h4h3 a2a3 h5h4 b2b3 c6c5 b4c5 g1f1 f2f1 b5b4 a3b4 a6a5 c5c6 a5b4 c2c3 b4c3 c6c7 c3c2 c7c8Q c2c1Q c8c1
info depth 22 seldepth 24 score cp 0 nodes 7918570 time 2466 nps 3210007 pv e1f1 h4h3 c2c3 h5h4 a2a3 c6c5 b4c5 g1f1 f2f1 b5b4 c5c6 b4a3 b2a3 a6a5 c6c7 a5a4 c7c8Q
info depth 23 seldepth 24 score cp 0 nodes 9383516 time 3002 nps 3125369 pv e1f1 h4h3 c2c3 h5h4 a2a3 c6c5 b4c5 g1f1 f2f1 b5b4 c5c6 b4a3 b2a3 a6a5 c6c7 a5a4 c7c8Q
info depth 24 seldepth 24 score cp 0 nodes 12567741 time 4212 nps 2983547 pv e1f1 h4h3 c2c3 h5h4 a2a3 c6c5 b4c5 g1f1 f2f1 b5b4 c5c6 b4a3 b2a3 a6a5 c6c7 a5a4 c7c8Q
info depth 25 seldepth 32 score cp 237 nodes 19792388 time 6915 nps 2862057 pv e1f1 h4h3 c2c3 h5h4 a2a3 c6c5 b4c5 b5b4 c5c6 b4c3 b2c3 a6a5 c6c7 a5a4 c7c8Q g1f1 f2e3 f1e1 e3d4 e1e2 c8g4 e2d2 d4c5 d2d3 c5b4 d3g3 g4h4
info depth 26 seldepth 34 score cp 260 nodes 53323340 time 19205 nps 2776396 pv e1f1 h4h3 c2c3 h5h4 a2a3 c6c5 b4c5 b5b4 c5c6 b4c3 b2c3 a6a5 c6c7 a5a4 c7c8Q g1f1 f2e3 f1e1 e3d3 e1f1 c8g4 f1f2 g4a4 f2f3 d3c2 h1g1 a4g4 f3g3 g4d4 g1f1
info depth 27 seldepth 36 score cp 301 nodes 114592725 time 42041 nps 2725680 pv e1f1 h4h3 c2c3 h5h4 a2a3 c6c5 b4c5 b5b4 c5c6 b4c3 b2c3 a6a5 c6c7 a5a4 c7c8Q g1f1 f2e2 f1f2 e2e3 h1g1 c8g4 g1f1 g4h3 f1g1 h3g4 g1f1 g4h4 f2g2 c3c4 f1g1

mvk
Posts: 589
Joined: Tue Jun 04, 2013 8:15 pm

Re: static mate/stalemate detection?

Post by mvk » Sat Nov 21, 2015 9:32 pm

I have always disabled null move when one side has no pieces. In this position I get a mate 10 score eventually.
[Account deleted]

brtzsnr
Posts: 433
Joined: Fri Jan 16, 2015 3:02 pm
Contact:

Re: static mate/stalemate detection?

Post by brtzsnr » Sun Nov 22, 2015 12:18 pm

I disable null-move for the side with no pieces. You can see that at depth 21 I get 705, but at depth 22 I get 0. In this case is only the horizon effect. Stockfish 5 doesn't find mate in 10 either, so I'm not worried about missed mate.

Ferdy
Posts: 4043
Joined: Sun Aug 10, 2008 1:15 pm
Location: Philippines

Re: static mate/stalemate detection?

Post by Ferdy » Sun Nov 22, 2015 1:43 pm

brtzsnr wrote:Does your engine detect stalemates/mates in the evaluation?

For example, zurichess for

[d] 8/8/8/8/7p/1P5p/7p/2Q2K1k b - - 0 11

says

Code: Select all

info depth 0 seldepth 0 score cp -705 nodes 2 time 0 nps 29835 pv
info depth 1 seldepth 0 score cp 0 nodes 3 time 0 nps 33204 pv
info depth 2 seldepth 0 score cp 0 nodes 4 time 0 nps 41210 pv
info depth 3 seldepth 0 score cp 0 nodes 5 time 0 nps 47778 pv
info depth 4 seldepth 0 score cp 0 nodes 6 time 0 nps 54364 pv
info depth 5 seldepth 0 score cp 0 nodes 7 time 0 nps 59142 pv
info depth 6 seldepth 0 score cp 0 nodes 8 time 0 nps 64675 pv
Deuterium does not.

Code: Select all

uci
id name Deuterium v2015.1.35.275
position fen 8/8/8/8/7p/1P5p/7p/2Q2K1k b - - 0 11
go movetime 20000
info time 0 nodes 0
bestmove 0000

Code: Select all

EEAI - EPD and Engine Analysis Interface v4.0

Intel(R) Core(TM) i7-2600K CPU @ 3.40GHz
Physical Cores: 4, Hyper-Threading: ON
Physical Memory: Total = 12 GB, Available = 7 GB

Engine: Deuterium v2015.1.35.275
Hash: 128, Threads: 1, Time: 30.0s/pos

Test file: cpw-zugzwang.epd, TotalPos 5
AnalyzedPos : 5, Correct: 3 (60.00%)

Total engine analysis time: 00h:02m:30s:037ms
Expected time to finish   : 00h:02m:30s:000ms

   Pos  Correct  EngineBM  ScoreCP    Mate    EPD
     1        1       Rf1     +315       -    8/8/p1p5/1p5p/1P5p/8/PPP2K1p/4R1rk w - - 0 1 bm Rf1; id "zugzwang.001";
     2        1       Kh6     +779       -    1q1k4/2Rr4/8/2Q3K1/8/8/8/8 w - - 0 1 bm Kh6;  id "zugzwang.002";
     3        0       Ke7       +0       -    7k/5K2/5P1p/3p4/6P1/3p4/8/8 w - - 0 1 bm g5; id "zugzwang.003";
     4        0      Bf6+       +0       -    8/6B1/p5p1/Pp4kp/1P5r/5P1Q/4q1PK/8 w - - 0 32 bm Qxh4; id "zugzwang.004";
     5        1      Nxd5       +0       -    8/8/1p1r1k2/p1pPN1p1/P3KnP1/1P6/8/3R4 b - - 0 1 bm Nxd5; id "zugzwang.005";

Joost Buijs
Posts: 927
Joined: Thu Jul 16, 2009 8:47 am
Location: Almere, The Netherlands

Re: static mate/stalemate detection?

Post by Joost Buijs » Sun Nov 22, 2015 2:52 pm

[d] 8/8/p1p5/1p5p/1P5p/8/PPP2K1p/4R1rk w - - 0 1

Nightmare finds a mate in 10 at depth 18.

It doesn't know anything about stale-mate in the static evaluation.
I check whether there is at least 1 piece that can move to a safe square and whether the king can move to a safe square as well before I enable null-move for that side.

Code: Select all

FEN: 8/8/p1p5/1p5p/1P5p/8/PPP2K1p/4R1rk w - - 0 1 

Nightmare MP:
   1	00:00	         251	251	-3.44	Kf2-e2
   2	00:00	         318	318	-3.13	Re1-e2
   3	00:00	         546	546	-3.13	Re1-e2 Rg1-g2+ Kf2-e3
   4	00:00	       1,648	1,648	-2.68	Re1-e6 Rg1-g2+ Kf2-f3 Rg2-g3+
   5	00:00	       3,391	3,391,000	-2.61	Re1-e6 Rg1-b1 a2-a3 h4-h3 b2-b3
   6	00:00	       6,695	3,347,500	-2.54	Re1-e6 Rg1-b1 a2-a3 h4-h3 b2-b3 Rb1-a1
   7	00:00	      13,140	3,285,000	-2.54	Re1-e6 Rg1-b1 a2-a3 h4-h3 b2-b3 Rb1-a1 Re6xc6
   8	00:00	      25,846	4,307,666	-1.82	Re1-f1 h4-h3 a2-a3 Rg1xf1+ Kf2xf1 c6-c5 b4xc5 a6-a5
   9	00:00	      31,605	3,950,625	-1.73	Re1-f1 h4-h3 a2-a3 h5-h4 b2-b3 Rg1xf1+ Kf2xf1 c6-c5 b4xc5
  10	00:00	      39,797	3,979,700	-0.89	Re1-f1 h4-h3 a2-a3 h5-h4 b2-b3 Rg1xf1+ Kf2xf1 c6-c5 b4xc5 a6-a5
  11	00:00	      53,020	3,787,142	+0.21	Re1-f1 h4-h3 a2-a3 h5-h4 c2-c3 Rg1xf1+ Kf2xf1 c6-c5 b4xc5 a6-a5 c5-c6
  12	00:00	      68,727	4,042,764	+0.21	Re1-f1 h4-h3 a2-a3 h5-h4 c2-c3 Rg1xf1+ Kf2xf1 c6-c5 b4xc5 a6-a5 c5-c6 a5-a4
  13	00:00	     100,309	4,012,360	+1.88	Re1-f1 h4-h3 c2-c3 h5-h4 b2-b3 Rg1xf1+ Kf2xf1 c6-c5 b4xc5
  14	00:00	     127,858	4,261,933	+1.97	Re1-f1 h4-h3 c2-c3 h5-h4 b2-b3 Rg1xf1+ Kf2xf1 a6-a5 b4xa5 b5-b4 c3xb4 c6-c5 b4-b5 c5-c4
  15	00:00	     183,398	4,473,121	+4.94	Re1-f1 h4-h3 c2-c3 h5-h4 a2-a3 Rg1xf1+ Kf2xf1 c6-c5 b4xc5 b5-b4 a3xb4 a6-a5 c5-c6 a5xb4 c6-c7
  16	00:00	     250,131	4,904,529	+4.94	Re1-f1 h4-h3 c2-c3 h5-h4 a2-a3 Rg1xf1+ Kf2xf1 c6-c5 b4xc5 b5-b4 a3xb4 a6-a5 c5-c6 a5xb4 c6-c7 b4xc3
  17	00:00	     380,408	5,283,444	+5.86	Re1-f1 h4-h3 c2-c3 h5-h4 a2-a3 Rg1xf1+ Kf2xf1 c6-c5 b4xc5 b5-b4 a3xb4 a6-a5 c5-c6 a5xb4 c6-c7 b4xc3 b2-b3
  18	00:04	  87,095,971	18,065,955	+M10	Re1-f1 h4-h3 c2-c3 h5-h4 b2-b3 Rg1xf1+ Kf2xf1 a6-a5 b4xa5 b5-b4 c3xb4 c6-c5 b4-b5 c5-c4 a5-a6 c4xb3 a6-a7 b3xa2
  19	00:10	 175,224,063	17,061,739	+M10	Re1-f1 h4-h3 c2-c3 h5-h4 b2-b3 Rg1xf1+ Kf2xf1 a6-a5 b4xa5 b5-b4 c3xb4 c6-c5 b4-b5 c5-c4 a5-a6 c4xb3 a6-a7 b3xa2 a7-a8Q+
  20	00:17	 283,951,820	16,128,127	+M10	Re1-f1 h4-h3 c2-c3 h5-h4 b2-b3 Rg1xf1+ Kf2xf1 a6-a5 b4xa5 b5-b4 c3xb4 c6-c5 b4-b5 c5-c4 a5-a6 c4xb3 a6-a7 b3xa2 a7-a8Q+

mvk
Posts: 589
Joined: Tue Jun 04, 2013 8:15 pm

Re: static mate/stalemate detection?

Post by mvk » Sun Nov 22, 2015 2:57 pm

brtzsnr wrote:I disable null-move for the side with no pieces. You can see that at depth 21 I get 705, but at depth 22 I get 0. In this case is only the horizon effect. Stockfish 5 doesn't find mate in 10 either, so I'm not worried about missed mate.
Remember that if one side is in zugzwang, then the other side is so as well: In the minimax of a zero-sum game, zugzwang is always mutual after all, because the mathematics forces it to be that way. (Ignore what some chess players claim about this matter.)
[Account deleted]

Post Reply