Godfrey Heathcote's (1902) 2-move mate - engine tester

Discussion of chess software programming and technical issues.

Moderator: Ras

R. Tomasi
Posts: 307
Joined: Wed Sep 01, 2021 4:08 pm
Location: Germany
Full name: Roland Tomasi

Re: Godfrey Heathcote's (1902) 2-move mate - engine tester

Post by R. Tomasi »

gflohr wrote: Sat Oct 02, 2021 3:12 pm Recent stockfish seems to fail this test:

Code: Select all

Stockfish 250721 by the Stockfish developers (see AUTHORS file)
position fen b4b2/3r4/3pr3/8/1K5N/2PR4/Q3p3/5kBR w - - 0 1
go depth 5
info string NNUE evaluation using nn-76a8a7ffb820.nnue enabled
info depth 1 seldepth 1 multipv 1 score cp 938 nodes 187 nps 93500 tbhits 0 time 2 pv a2e6 a8h1
info depth 2 seldepth 2 multipv 1 score cp 1339 nodes 625 nps 208333 tbhits 0 time 3 pv a2a8 e2e1n a8f8 f1e2
info depth 3 seldepth 3 multipv 1 score cp 1339 nodes 708 nps 236000 tbhits 0 time 3 pv a2a8 e2e1n a8f8 f1e2
info depth 4 seldepth 4 multipv 1 score cp 1339 nodes 783 nps 261000 tbhits 0 time 3 pv a2a8 e2e1n a8f8 f1e2
info depth 5 seldepth 5 multipv 1 score cp 1100 nodes 1902 nps 380400 tbhits 0 time 5 pv a2a8 e2e1n h4f3 d6d5 g1c5 f1g2
bestmove a2a8 ponder e2e1n
You need to allow it to search a little deeper. Engines that do pruning will only see mates at a little bit deeper search depth (but in less time).
User avatar
Ras
Posts: 2703
Joined: Tue Aug 30, 2016 8:19 pm
Full name: Rasmus Althoff

Re: Godfrey Heathcote's (1902) 2-move mate - engine tester

Post by Ras »

gflohr wrote: Sat Oct 02, 2021 3:12 pmBut what is the correct output here? "mate 1" or "mate 2"? Does the move to make count or not?
Should be "mate 2" because it refers to the position as given, i.e. without the bestmove having been made.
Rasmus Althoff
https://www.ct800.net
gflohr
Posts: 57
Joined: Fri Jul 23, 2021 5:24 pm
Location: Elin Pelin
Full name: Guido Flohr

Re: Godfrey Heathcote's (1902) 2-move mate - engine tester

Post by gflohr »

R. Tomasi wrote: Sat Oct 02, 2021 3:27 pm
gflohr wrote: Sat Oct 02, 2021 3:12 pm Recent stockfish seems to fail this test:
You need to allow it to search a little deeper. Engines that do pruning will only see mates at a little bit deeper search depth (but in less time).
Even with "go infinite" it only finds a mate in 5. Same for komodo, by the way.
Chessnut1071
Posts: 313
Joined: Tue Aug 03, 2021 2:41 pm
Full name: Bill Beame

Re: Godfrey F. Heathcote's (1904) 2-move mate: engine tester.

Post by Chessnut1071 »

Ajedrecista wrote: Sat Oct 02, 2021 2:37 pm Hello:

@Bill: The year of the problem is 1904 instead of 1902, according to multiple sources cited at Yet Another Chess Problem Database:

https://yacpdb.org/#32778

This problem is amazing, like many other two-movers composed in 19th and early 20th centuries. People were so creative! And they still are. :-)

------------

@Daniel:

With a checkmate in X moves problem with the side to move being the winning side, the problem lasts 2X - 1 plies and not 2X plies. For example, in this case, sides to move are white, black and white (giving checkmate).

Regarding perft, you have another chance to test your move generator with perft(9) of this problem:

Code: Select all

b4b2/3r4/3pr3/8/1K5N/2PR4/Q3p3/5kBR w - - 0 1

Qxe6       606,549,944,991
Rxd6     1,107,966,964,258
Qxa8       592,965,195,122
Qxe2+       21,695,658,538
Ng6      2,359,047,289,324
Nf5      2,654,509,538,975
Nf3      1,784,571,051,456
Ng2      1,736,567,066,602
Qd5        969,963,756,463
Qc4      1,097,964,376,220
Qb3        929,406,983,982
Qb1+       117,012,074,815
Ba7+        43,808,336,233
Bb6+        56,481,695,781
Bc5+        53,212,630,286
Bd4+        51,456,582,207
Be3+        54,244,193,549
Bf2+        97,584,763,987
Bh2+        96,587,846,251
Rd5        963,493,575,113
Rd4      1,236,586,738,232
Re3      1,024,283,619,200
Rf3+        43,576,929,238
Rg3      1,340,199,052,614
Rdh3       822,824,235,023
Rd2      1,211,610,571,630
Rd1+       239,317,287,488
Qa7      1,313,790,835,575
Qa6      1,158,270,547,557
Qa5      1,415,643,029,295
Qa4      1,164,837,317,601
Qa3        926,760,230,691
Qb2        792,811,187,475
Qc2        792,444,078,042
Qd2        738,525,717,822
Qa1+       146,045,179,540
Rhh3     2,364,120,821,585
Rh2      2,417,276,365,519
c4       1,208,342,032,837
Ka5      1,051,917,564,051
Kb5      1,283,767,403,954
Ka4        934,369,905,939
Kc4        834,880,520,162
Ka3        883,628,534,682
Kb3      1,205,810,153,778
TOTAL   41,946,729,383,683
This perft(9) value was computed with gperft perft counter.

Regards from Spain.

Ajedrecista.
ply = 2x-1 seems logical, however, I know of no way to determine if there is a forced mate without checking the 4th ply. How are you sure without checking if the other side can reply?
User avatar
emadsen
Posts: 441
Joined: Thu Apr 26, 2012 1:51 am
Location: Oak Park, IL, USA
Full name: Erik Madsen

Re: Godfrey Heathcote's (1902) 2-move mate - engine tester

Post by emadsen »

gflohr wrote: Sat Oct 02, 2021 3:12 pm Recent stockfish seems to fail this test:

Code: Select all

Stockfish 250721 by the Stockfish developers (see AUTHORS file)
position fen b4b2/3r4/3pr3/8/1K5N/2PR4/Q3p3/5kBR w - - 0 1
go depth 5
info string NNUE evaluation using nn-76a8a7ffb820.nnue enabled
info depth 1 seldepth 1 multipv 1 score cp 938 nodes 187 nps 93500 tbhits 0 time 2 pv a2e6 a8h1
info depth 2 seldepth 2 multipv 1 score cp 1339 nodes 625 nps 208333 tbhits 0 time 3 pv a2a8 e2e1n a8f8 f1e2
info depth 3 seldepth 3 multipv 1 score cp 1339 nodes 708 nps 236000 tbhits 0 time 3 pv a2a8 e2e1n a8f8 f1e2
info depth 4 seldepth 4 multipv 1 score cp 1339 nodes 783 nps 261000 tbhits 0 time 3 pv a2a8 e2e1n a8f8 f1e2
info depth 5 seldepth 5 multipv 1 score cp 1100 nodes 1902 nps 380400 tbhits 0 time 5 pv a2a8 e2e1n h4f3 d6d5 g1c5 f1g2
bestmove a2a8 ponder e2e1n
Stockfish is not failing. Chess engines are optimized for playing strength per unit time. Why? Because chess games are played with a clock. Contrary to Hollywood's depictions, computer artificial intelligence doesn't dominate by brute force. Its strength comes from selectivity. In the specific case of computer chess engines, their strength comes from selectively examining certain moves deeper than other moves. Any "blindness" caused by this selectivity is compensated for by iterative deepening... search to depth 1, then depth 2, then depth 3, etc until the time allotted for the current move has expired. Strong moves "overlooked" at shallower depths will be found at deeper depths when reductions and pruning are not severe enough to cause the engine to miss the move.

In this framework, "depth" represents nominal depth, not exhaustive depth.
gflohr wrote: Sat Oct 02, 2021 3:12 pm With "go mate" it also does not find the mate.
"Go mate" is not a proper UCI command. The "go mate" command requires a move count parameter. Enter "go mate 2" and you'll see Stockfish solves the problem.
gflohr wrote: Sat Oct 02, 2021 3:12 pm But what is the correct output here? "mate 1" or "mate 2"? Does the move to make count or not?
Mate 2 is correct because the side-to-move must move twice. Mate distance is based on the side-to-move, not the defending side.
Erik Madsen | My C# chess engine: https://www.madchess.net
JVMerlino
Posts: 1404
Joined: Wed Mar 08, 2006 10:15 pm
Location: San Francisco, California

Re: Godfrey Heathcote's (1902) 2-move mate - engine tester

Post by JVMerlino »

No surprise that The King from CM9000 has little trouble:

Code: Select all

Time	Depth	Score	Positions	Moves
0:00	1/3	Mate04	4808		1.Qc4 Ke1 2.Bf2+ Kxf2 3.Qd4+ Re3 4.Qxe3#
0:00	1/4	Mate03	12230		1.Qc4 Ke1 2.Qf4 Bxh1 3.Qf2#
0:00	1/4	Mate02	23909		1.Qa6 Bxh1 2.Rd1#
0:00	1/5	Mate02	24090		1.Qa6 Bxh1 2.Rd1#
0:00	1/6	Mate02	29027		1.Qa6 Bxh1 2.Rd1#
0:00	1/7	Mate02	30895		1.Qa6 Bxh1 2.Rd1#
0:00	1/8	Mate02	35568		1.Qa6 Bxh1 2.Rd1#
0:00	1/9	Mate02	44814		1.Qa6 Bxh1 2.Rd1#
0:00	2/10	Mate02	56655		1.Qa6 Bxh1 2.Rd1#
0:00	3/11	Mate02	61201		1.Qa6 Bxh1 2.Rd1#
JVMerlino
Posts: 1404
Joined: Wed Mar 08, 2006 10:15 pm
Location: San Francisco, California

Re: Godfrey Heathcote's (1902) 2-move mate - engine tester

Post by JVMerlino »

Myrddin has a little more trouble, but not much:

Code: Select all

 6  32758      4        54422 a2a8 e2e1N d3f3 f1e2 h1h2 e1g2 h2g2 e2d1 a8a1 (1157 KNPS)(Mate in 5)
 7  32758      6        73714 a2a8 e2e1N d3f3 f1e2 h1h2 e1g2 h2g2 e2d1 a8a1 (1170 KNPS)(Mate in 5)
 7  32764      9       134818 a2a6 a8h1 d3d1 (1434 KNPS)(Mate in 2)
 8  32764      9       136520 a2a6 a8h1 d3d1 (1452 KNPS)(Mate in 2)
 9  32764     10       178279 a2a6 a8h1 d3d1 (1635 KNPS)(Mate in 2)
User avatar
Ajedrecista
Posts: 2134
Joined: Wed Jul 13, 2011 9:04 pm
Location: Madrid, Spain.

Re: Godfrey F. Heathcote's (1904) 2-move mate: engine tester.

Post by Ajedrecista »

Hello Bill:
Chessnut1071 wrote: Sat Oct 02, 2021 3:55 pmply = 2x-1 seems logical, however, I know of no way to determine if there is a forced mate without checking the 4th ply. How are you sure without checking if the other side can reply?
I was talking about the OTB length of the problem itself (for example: 1.- Qa6, d5+; 2.- Bc5#) and not about the programming method to ensure the correctness of the solution, since I understood that Daniel was talking about detecting 'a checkmate in 4 plies in the tree', but he may wanted to say checkmate in 3, then add the last ply to check if the other side can move.

--------------

Regarding the year of the problem, I found 1904 (like in YACPDB) in a reprint of the problem in The Weekly Times of Melbourne of February 10th, 1940 (this source is not listed at YACPDB at the current date of this post). The solution is given in the issue of March 2nd, 1940:

[1940/02/10] The Weekly Times of Melbourne (No. 3686), page 64 {PROBLEM No. 5891}.
[1940/03/02] The Weekly Times of Melbourne (No. 3689), page 64 {PROBLEM No. 5891}.

I find very curious that back in 1940 and surely earlier, this newspaper used a pseudo-FEN notation:

Code: Select all

b4b2 | 3r4 | 3pr3 | 8 | 1K5N | 2PR4 | Q3p3 | 5kBR.
White to play and mate in two moves.
I have just learned from FEN article at CPW that the modern FEN is based in works from 19th century!

Regards from Spain.

Ajedrecista.
op12no2
Posts: 553
Joined: Tue Feb 04, 2014 12:25 pm
Location: Gower, Wales
Full name: Colin Jenkins

Re: Godfrey Heathcote's (1902) 2-move mate - engine tester

Post by op12no2 »

It takes Lozza to ply 6 so fails, but I do stop at the top level on the first mate. The mate reporting looks wrong too.

Code: Select all

0.25 6/13 (4mate) Qxa8 e1=N Rf3 Ke2 Rh2 Ng2 #
0.2 5/13 (1903cp) Qxa8 e1=N Rf3 Ke2 Rh2
0.15 4/13 (1686cp) Qxa8 e1=N Qxf8 Ke2
0.11 3/13 (1703cp) Qxa8 e1=N Qxf8
0.1 3/13 (1034cp) Nf3 Re8 Be3
0.01 2/7 (867cp) Nf3 Bxf3
0.01 1/7 (862cp) Nf3
0.01 1/6 (802cp) Qxa8
0.01 1/6 (668cp) Qxe6
Live version (uses a little CPU):-

https://op12no2.github.io/lozza-ui/fen. ... 01&act=ana
Ferdy
Posts: 4851
Joined: Sun Aug 10, 2008 3:15 pm
Location: Philippines

Re: Godfrey Heathcote's (1902) 2-move mate - engine tester

Post by Ferdy »

Here is Matalino based from julia chess library.

Code: Select all

julia matalino.jl
info string Matalino v0.12.0, a uci chess engine written in julia!
uci
id name Matalino v0.12.0
id author Ferdinand Mosca
option name UseNullMovePruning type check default true
isready
readyok
position fen b4b2/3r4/3pr3/8/1K5N/2PR4/Q3p3/5kBR w 0 1
b
Board (b4b2/3r4/3pr3/8/1K5N/2PR4/Q3p3/5kBR w - -):
 b  -  -  -  -  b  -  -
 -  -  -  r  -  -  -  -
 -  -  -  p  r  -  -  -
 -  -  -  -  -  -  -  -
 -  K  -  -  -  -  -  N
 -  -  P  R  -  -  -  -
 Q  -  -  -  p  -  -  -
 -  -  -  -  -  k  B  R
go movetime 30000
info string move allocation time 29900
info depth 1 score cp 719 nodes 555 nps 25228 time 22 pv h4f3
info depth 2 score cp 720 nodes 3288 nps 60889 time 54 pv h4f3 e6e8
info depth 3 score cp 31997 nodes 14785 nps 111166 time 133 pv a2a6 e2e1q d3f3
info depth 4 score cp 31997 nodes 60438 nps 199466 time 303 pv a2a6 e2e1q d3f3
info depth 5 score cp 31997 nodes 391685 nps 258880 time 1513 pv a2a6 e2e1q d3f3
info depth 6 score cp 31997 nodes 2583653 nps 261002 time 9899 pv a2a6 e2e1q d3f3
info nodes 7338000 nps 245410 time 29901
bestmove a2a6