Compare your engine's performance: Corrections +++

Discussion of chess software programming and technical issues.

Moderator: Ras

federico
Posts: 32
Joined: Sun Oct 22, 2017 4:36 am
Location: Canada
Full name: Federico Rojo

Re: Compare your engine's performance: Corrections +++

Post by federico »

lithander wrote: Thu Aug 19, 2021 12:55 pm MinimalChess 0.59 doesn't use reductions or extensions and finds a mate after 13 plys:

Code: Select all

position fen 5k2/ppp2r1p/2p2ppP/8/2Q5/2P1bN2/PP4P1/1K1R4 w - - 0 1
go
info string Search scheduled to take 715827862ms!
info depth 1 score cp 1001 nodes 117 nps 4034 time 29 pv c4b4
info depth 2 score cp 906 nodes 432 nps 12705 time 34 pv d1d8 f8e7
info depth 3 score cp 986 nodes 1410 nps 37105 time 38 pv d1d8 f8e7 d8d7
info depth 4 score cp 930 nodes 2878 nps 68523 time 42 pv c4b4 c6c5 b4b7 e3h6
info depth 5 score cp 987 nodes 5817 nps 103875 time 56 pv c4b4 c6c5 b4b7 e3h6 b7a8
info depth 6 score cp 974 nodes 19299 nps 189205 time 102 pv d1d8 f8e7 d8c8 e3b6 c8b8 f7f8
info depth 7 score cp 1130 nodes 33827 nps 194408 time 174 pv d1d8 f8e7 c4d3 f6f5 d8d7 e7e6 d7f7
info depth 8 score cp 1128 nodes 46310 nps 201347 time 230 pv d1d8 f8e7 c4d3 f6f5 d8d7 e7e6 d7f7 e6f7
info depth 9 score cp 1371 nodes 149765 nps 282575 time 530 pv d1d8 f8e7 d8c8 f7f8 c4e4 e7f7 c8c7 f7g8 e4e6
info depth 10 score cp 1328 nodes 227306 nps 334273 time 680 pv d1d8 f8e7 d8c8 f7f8 c4e4 e7d7 c8f8 e3h6 e4d4 d7e6
info depth 11 score cp 1456 nodes 678053 nps 407974 time 1662 pv d1d8 f8e7 d8c8 f7f8 c8c7 e7d6 c7b7 c6c5 c4d3 e3d4 d3a6
info depth 12 score cp 1425 nodes 1140933 nps 441025 time 2587 pv d1d8 f8e7 c4d3 f6f5 d8h8 e3c5 d3d8 e7e6 f3g5 e6e5 g5f7 e5e4
info depth 13 score mate 7 nodes 4437734 nps 479185 time 9261 pv c4e6 e3h6 d1d8 f8g7 f3e5 f6e5 e6e5 f7f6 d8d7 g7h8 e5f6 h8g8 f6f7
bestmove c4e6
But I don't think that this line does actually lead to a mate in 7 as reported but a mate in 8. I suppose QSearch just returns with an evaluation of Mate for the final position and so after 13 plys MinimalChess thinks it has reached a mate in 13 plys, not considering the moves that have been going on within QSearch. Do you guys extend the PV in Qsearch as well? Or how do you get the correct mate distance?

Just let the engine go deeper and while it does , some of the moves that were being pruned and lead to a shorter mate will surface.
Based on your engine's output, i assume you have coded it to stop as soon as a mate is found. remove that and let it run.
JVMerlino
Posts: 1404
Joined: Wed Mar 08, 2006 10:15 pm
Location: San Francisco, California

Re: Compare your engine's performance: Corrections +++

Post by JVMerlino »

federico wrote: Thu Aug 19, 2021 4:34 pm
lithander wrote: Thu Aug 19, 2021 12:55 pm MinimalChess 0.59 doesn't use reductions or extensions and finds a mate after 13 plys:

Code: Select all

position fen 5k2/ppp2r1p/2p2ppP/8/2Q5/2P1bN2/PP4P1/1K1R4 w - - 0 1
info depth 13 score mate 7 nodes 4437734 nps 479185 time 9261 pv c4e6 e3h6 d1d8 f8g7 f3e5 f6e5 e6e5 f7f6 d8d7 g7h8 e5f6 h8g8 f6f7
bestmove c4e6
But I don't think that this line does actually lead to a mate in 7 as reported but a mate in 8. I suppose QSearch just returns with an evaluation of Mate for the final position and so after 13 plys MinimalChess thinks it has reached a mate in 13 plys, not considering the moves that have been going on within QSearch. Do you guys extend the PV in Qsearch as well? Or how do you get the correct mate distance?

Just let the engine go deeper and while it does , some of the moves that were being pruned and lead to a shorter mate will surface.
Based on your engine's output, i assume you have coded it to stop as soon as a mate is found. remove that and let it run.
You are correct that your final PV is not a mate in 7, but rather mate in 8. The last move in the PV is not checkmate, but that could simply be because the PV was cut off due to a TT hit. After f6f7, there should be g8h8 f7h7, which is mate.
Chessnut1071
Posts: 313
Joined: Tue Aug 03, 2021 2:41 pm
Full name: Bill Beame

Re: Compare your engine's performance: Corrections +++

Post by Chessnut1071 »

JVMerlino wrote: Thu Aug 19, 2021 5:44 pm
federico wrote: Thu Aug 19, 2021 4:34 pm
lithander wrote: Thu Aug 19, 2021 12:55 pm MinimalChess 0.59 doesn't use reductions or extensions and finds a mate after 13 plys:

Code: Select all

position fen 5k2/ppp2r1p/2p2ppP/8/2Q5/2P1bN2/PP4P1/1K1R4 w - - 0 1
info depth 13 score mate 7 nodes 4437734 nps 479185 time 9261 pv c4e6 e3h6 d1d8 f8g7 f3e5 f6e5 e6e5 f7f6 d8d7 g7h8 e5f6 h8g8 f6f7
bestmove c4e6
But I don't think that this line does actually lead to a mate in 7 as reported but a mate in 8. I suppose QSearch just returns with an evaluation of Mate for the final position and so after 13 plys MinimalChess thinks it has reached a mate in 13 plys, not considering the moves that have been going on within QSearch. Do you guys extend the PV in Qsearch as well? Or how do you get the correct mate distance?

Just let the engine go deeper and while it does , some of the moves that were being pruned and lead to a shorter mate will surface.
Based on your engine's output, i assume you have coded it to stop as soon as a mate is found. remove that and let it run.
You are correct that your final PV is not a mate in 7, but rather mate in 8. The last move in the PV is not checkmate, but that could simply be because the PV was cut off due to a TT hit. After f6f7, there should be g8h8 f7h7, which is mate.
The correct solution:
1 Qe4 2 Bxp
2 Rd8+ Kg7
3 Nd4 Bf4 also, I think Bd2 also works
4 Ne6+ Kh6
5 Rd1 pc5
6 Rh1+ Bh2
7 Rxh2#
JVMerlino
Posts: 1404
Joined: Wed Mar 08, 2006 10:15 pm
Location: San Francisco, California

Re: Compare your engine's performance: Corrections +++

Post by JVMerlino »

Chessnut1071 wrote: Thu Aug 19, 2021 6:57 pm The correct solution:
1 Qe4 2 Bxp
2 Rd8+ Kg7
3 Nd4 Bf4 also, I think Bd2 also works
4 Ne6+ Kh6
5 Rd1 pc5
6 Rh1+ Bh2
7 Rxh2#
In your line, Black has three choices at move 3 that all lead to mate in 4: Bf4, Rf8 and Bg5.
3...Bd2 leads to mate in 2 with 4.Ne6+ Kh6 5.Qh4#

This is also a solution if Black plays 1.Bd2....
1.Qe4 Bd2
2.Rxd2 Re7
3.Rd8+ Kf7
4.Qc4+ Re6
5.Rd7+ ....

Now Black has three king moves that all have slightly different mate in 2 lines.
John Merlino - Myrddin chess engine
User avatar
Ras
Posts: 2703
Joined: Tue Aug 30, 2016 8:19 pm
Full name: Rasmus Althoff

Re: Compare your engine's performance: Corrections +++

Post by Ras »

JVMerlino wrote: Thu Aug 19, 2021 4:30 amBecause I used Chessmaster's mate finder, and it took only five seconds to confirm that there was no mate in 6. But it took another fifty seconds to confirm the mate in 7.
The mate search mode of my engine agrees:

Code: Select all

position fen 5k2/ppp2r1p/2p2ppP/8/2Q5/2P1bN2/PP4P1/1K1R4/ w
go mate 6
(...)
info depth 11 seldepth 11 score cp 0 time 33132 nodes 24961453 nps 753394 hashfull 0 tbhits 0
info string error (no mate found)
bestmove 0000
While also agreeing that it is a forced mate in 7, i.e. no black defence was overlooked:

Code: Select all

position fen 5k2/ppp2r1p/2p2ppP/8/2Q5/2P1bN2/PP4P1/1K1R4/ w
go mate 7
(...)
info depth 13 seldepth 13 score mate 7 time 435590 nodes 340582076 nps 781886 hashfull 0 tbhits 0 pv c4e4 e3h6 d1d8 f8g7 f3d4 h6g5 d4e6 g7h6 e4g4 b7b5 g4h3 g5h4 h3h4
bestmove c4e4
Rasmus Althoff
https://www.ct800.net
amanjpro
Posts: 883
Joined: Sat Mar 13, 2021 1:47 am
Full name: Amanj Sherwany

Re: Compare your engine's performance: Corrections +++

Post by amanjpro »

Ras wrote: Thu Aug 19, 2021 9:22 pm
JVMerlino wrote: Thu Aug 19, 2021 4:30 amBecause I used Chessmaster's mate finder, and it took only five seconds to confirm that there was no mate in 6. But it took another fifty seconds to confirm the mate in 7.
The mate search mode of my engine agrees:

Code: Select all

position fen 5k2/ppp2r1p/2p2ppP/8/2Q5/2P1bN2/PP4P1/1K1R4/ w
go mate 6
(...)
info depth 11 seldepth 11 score cp 0 time 33132 nodes 24961453 nps 753394 hashfull 0 tbhits 0
info string error (no mate found)
bestmove 0000
While also agreeing that it is a forced mate in 7, i.e. no black defence was overlooked:

Code: Select all

position fen 5k2/ppp2r1p/2p2ppP/8/2Q5/2P1bN2/PP4P1/1K1R4/ w
go mate 7
(...)
info depth 13 seldepth 13 score mate 7 time 435590 nodes 340582076 nps 781886 hashfull 0 tbhits 0 pv c4e4 e3h6 d1d8 f8g7 f3d4 h6g5 d4e6 g7h6 e4g4 b7b5 g4h3 g5h4 h3h4
bestmove c4e4
How did you implement mate search mode? Does it use no prunning or what?
User avatar
Ras
Posts: 2703
Joined: Tue Aug 30, 2016 8:19 pm
Full name: Rasmus Althoff

Re: Compare your engine's performance: Corrections +++

Post by Ras »

amanjpro wrote: Thu Aug 19, 2021 9:27 pmHow did you implement mate search mode? Does it use no prunning or what?
There is no pruning, only AB-cuts, but with some special features. It ranks moves via MVV/LVA, depth killers, and history, but ranks check-delivering moves above all.

There's a special algorithm that will first only search check-delivering moves for the side that is supposed to deliver mate while always allowing all moves for the other side. If that fails, non-check delivering moves will be considered at root (depth 0). If that also fails, non-check delivering moves will be considered one move later (depth 2), and so on. The last depth level must always deliver check, or else it cannot be checkmate.

That is based on the observation that most mate puzzles include a series of checks later down the road. It doesn't work well with puzzles that are instead based on zugzwang, though. The hashfull indication is a bit misleading as it does use the hashtables, but only to indicate draw positions, i.e. those where no checkmate is possible within the given move limit. It's just that the hashtables are cleared before returning the bestmove, which is why the hashfull indication is 0 at that point.

One nice feature of the mate searcher in the microcontroller version is that the user can choose to search for secondary root moves after a valid solution has been found to detect double solutions. The UCI version relies on a GUI being able to use "searchmoves" for that to exclude the solution moves that were found previously.
Rasmus Althoff
https://www.ct800.net
JohnWoe
Posts: 529
Joined: Sat Mar 02, 2013 11:31 pm

Re: Compare your engine's performance: Corrections +++

Post by JohnWoe »

Mayhem 6.0:
Finds only Ng5 mate 10minutes / 740M nodes. Too much pruning going on.
CPU: AMD Athlon(tm) II X3 445 Processor

Code: Select all

exclude: none best +tail                                          
dep	score	nodes	time	(not shown:  tbhits	knps	seldep)
 18	+104,85 	739,2M	10:00.94	Ng5 
 17	+104,85 	739,2M	10:00.94	Ng5 
 16	+8,43 	535,5M	7:15.93	Rd8+ 
 15	+8,42 	313,6M	4:13.72	Rd8+ 
 14	+8,41 	84,5M  	1:05.14	Rd8+ 
 13	+8,34 	53,5M  	0:41.90	Rd8+ 
 12	+8,15 	36,8M  	0:28.90	Qb3 
 11	+8,13 	7,74M  	0:06.04	Rd8+ 
 10	+8,39 	2,07M  	0:01.63	Qe6 
  9	+8,17 	836230	0:00.65	Qe6 
  8	+8,38 	559022	0:00.47	Qe6 
  7	+8,28 	319470	0:00.29	Qe6 
  6	+8,39 	127924	0:00.12	Kc2 
  5	+6,97 	60733  	0:00.06	Qxf7+ 
  4	+8,60 	19584  	0:00.02	Kc2 
  3	+6,04 	6357    	0:00.01	Qh4 
  2	+8,62 	1336    	0:00.00	Kc2 
  1	+4,90 	92        	0:00.00	Qxf7+ 
  0	# 
Chessnut1071
Posts: 313
Joined: Tue Aug 03, 2021 2:41 pm
Full name: Bill Beame

Re: Compare your engine's performance: Corrections +++

Post by Chessnut1071 »

Ras wrote: Thu Aug 19, 2021 11:47 pm
amanjpro wrote: Thu Aug 19, 2021 9:27 pmHow did you implement mate search mode? Does it use no prunning or what?
There is no pruning, only AB-cuts, but with some special features. It ranks moves via MVV/LVA, depth killers, and history, but ranks check-delivering moves above all.

There's a special algorithm that will first only search check-delivering moves for the side that is supposed to deliver mate while always allowing all moves for the other side. If that fails, non-check delivering moves will be considered at root (depth 0). If that also fails, non-check delivering moves will be considered one move later (depth 2), and so on. The last depth level must always deliver check, or else it cannot be checkmate.

That is based on the observation that most mate puzzles include a series of checks later down the road. It doesn't work well with puzzles that are instead based on zugzwang, though. The hashfull indication is a bit misleading as it does use the hashtables, but only to indicate draw positions, i.e. those where no checkmate is possible within the given move limit. It's just that the hashtables are cleared before returning the bestmove, which is why the hashfull indication is 0 at that point.

One nice feature of the mate searcher in the microcontroller version is that the user can choose to search for secondary root moves after a valid solution has been found to detect double solutions. The UCI version relies on a GUI being able to use "searchmoves" for that to exclude the solution moves that were found previously.
Interesting text. I have a mate finder with most of the same metrics, but, a modified MVV-LVV. It uses the actual material consequences of the move set instead. The algorithms uses alpha-beta, history, material consequence and check. The following optimized weights were calculated over 230 chess puzzles from 5-ply - 21-ply: white: History-31.331, material consequence=2.906, check 42,796 Black: History=.003, material consequence = .723, check=130.907. Every other metric I tested had no significant improvement other than these 6 metrics, 3 for white and 3 for black. It's slow, but, it found every 230 puzzles I tested. If you use pruning, you can find a little better than 94% of the mates under 12-ply, but, that number really decreases at higher search depths. I really want to find out how chessmaster finds all the above mates in under a minute.

I'm wondering if chessmaster has a database of every published mate and found it in a database search. I can't believe that time. Anybody know how they did it?
JVMerlino
Posts: 1404
Joined: Wed Mar 08, 2006 10:15 pm
Location: San Francisco, California

Re: Compare your engine's performance: Corrections +++

Post by JVMerlino »

Chessnut1071 wrote: Fri Aug 20, 2021 2:10 am I really want to find out how chessmaster finds all the above mates in under a minute.

I'm wondering if chessmaster has a database of every published mate and found it in a database search. I can't believe that time. Anybody know how they did it?
Johan spent a great deal of time not only making The King an excellent mate-finder for its day, but also ensuring that every mate it found was absolutely correct. He never told me his method, though.