Basic endgames

Discussion of chess software programming and technical issues.

Moderators: bob, hgm, Harvey Williamson

Forum rules
This textbox is used to restore diagrams posted with the [d] tag before the upgrade.
User avatar
xr_a_y
Posts: 778
Joined: Sat Nov 25, 2017 1:28 pm
Location: France

Re: Basic endgames

Post by xr_a_y » Sat Sep 21, 2019 5:21 pm

flok wrote:
Sat Sep 21, 2019 4:57 pm
Guenther wrote:
Sat Sep 21, 2019 8:29 am
flok wrote:
Mon Sep 16, 2019 6:29 pm
Micah, depth 18, 3548ms for mate score on an i7-8750H @ 2.2GHz

Code: Select all

2 cores: 2325 ms
3 cores: 2094 ms
4 cores: 1604 ms
5 cores: 1638 ms
6 cores: 955ms

Code: Select all

folkert@msi:~/Projects/git/Micah$ ./Micah 
position fen 4k3/8/8/R7/4K3/8/8/8 w - -
go depth 50
# took 0ms
# TB_RESULT_FAILED
info depth 1 score cp 0 nodes 27 time 0 nps 391253 pv a5a8
...
info depth 17 score cp 0 nodes 3117427 time 1326 nps 2349866 pv a5a8 e8d7 a8h8 d7c6 e4d3 c6b5 d3c2 b5a4 c2b1 a4a3 b1a1 a3b4 h8a8 b4c5 a8h8 c5d6 h8a8 d6e7 a8h8 e7d6 h8a8 d6e7 a8h8 e7d6 h8a8 d6e7 a8h8 e7d6
info depth 18 score cp 9978 nodes 8182666 time 3548 nps 2305941 pv a5a7 e8f8 e4d5 f8e8 d5e6 e8f8 a7e7 f8g8 e7f7 g8h8 e6f6 h8g8 f6g6 g8h8 f7e7 h8g8 e7e8
Giving a score of 0.00 until resolving the mate is strange.
Any suggestions for rules that could "hit" this?
If 0 is return, then a draw is preferred, probably because putting king on side is not rewarded.

User avatar
hgm
Posts: 23772
Joined: Fri Mar 10, 2006 9:06 am
Location: Amsterdam
Full name: H G Muller
Contact:

Re: Basic endgames

Post by hgm » Sun Sep 22, 2019 8:51 am

Seems to me that a static evaluation that returns 0 when you are a Rook ahead must be badly broken...

User avatar
flok
Posts: 201
Joined: Tue Jul 03, 2018 8:19 am
Full name: Folkert van Heusden
Contact:

Re: Basic endgames

Post by flok » Sun Sep 22, 2019 5:16 pm

hgm wrote:
Sun Sep 22, 2019 8:51 am
Seems to me that a static evaluation that returns 0 when you are a Rook ahead must be badly broken...
I think I ran it without its tune.dat :oops:

Code: Select all

folkert@msi:~/Projects/git/Micah$ ./Micah 
Applying value 45 to key 'tune_bishop_count'
Applying value 7 to key 'tune_too_many_pawns'
Applying value -4 to key 'tune_zero_pawns'
Applying value -20 to key 'tune_isolated_pawns'
Applying value 26 to key 'tune_rook_on_open_file'
Applying value 8 to key 'tune_double_pawns'
Applying value 167 to key 'tune_bishop_open_diagonal'
Applying value 82 to key 'tune_pawn'
Applying value 368 to key 'tune_knight'
Applying value 369 to key 'tune_bishop'
Applying value 604 to key 'tune_rook'
Applying value 1210 to key 'tune_queen'
Applying value 5 to key 'tune_king_shield'
Applying value -142 to key 'tune_psq_mul'
Applying value -196 to key 'tune_psq_div'
Applying value -3 to key 'tune_pp_scores_mg_1'
Applying value -3 to key 'tune_pp_scores_mg_2'
Applying value 12 to key 'tune_pp_scores_mg_3'
Applying value 30 to key 'tune_pp_scores_mg_4'
Applying value 69 to key 'tune_pp_scores_mg_5'
Applying value 113 to key 'tune_pp_scores_mg_6'
Applying value -43 to key 'tune_pp_scores_eg_1'
Applying value -74 to key 'tune_pp_scores_eg_2'
Applying value -161 to key 'tune_pp_scores_eg_3'
Applying value 58 to key 'tune_pp_scores_eg_4'
Applying value 283 to key 'tune_pp_scores_eg_5'
Applying value 62 to key 'tune_pp_scores_eg_6'
position fen 4k3/8/8/R7/4K3/8/8/8 w - -
go depth 50
# took 0ms
# TB_RESULT_FAILED
info depth 1 score cp 677 nodes 27 time 0 nps 254935 pv a5a7
info depth 2 score cp 678 nodes 118 time 0 nps 377090 pv a5a7 e8f8
info depth 3 score cp 686 nodes 345 time 0 nps 470489 pv a5a7 e8f8 e4d5
info depth 4 score cp 685 nodes 1315 time 2 nps 563434 pv a5a7 e8f8 e4d5 f8e8
info depth 5 score cp 691 nodes 2742 time 5 nps 525043 pv a5a7 e8f8 e4d5 f8e8 d5d6
info depth 6 score cp 692 nodes 5136 time 6 nps 818977 pv a5a7 e8f8 e4d5 f8e8 d5d6 e8f8
info depth 7 score cp 696 nodes 8975 time 7 nps 1158335 pv a5a7 e8f8 e4d5 f8e8 d5d6 e8f8 a7e7
info depth 8 score cp 696 nodes 14630 time 9 nps 1482079 pv a5a7 e8f8 e4d5 f8e8 d5d6 e8f8 a7e7 f8g8
info depth 9 score cp 699 nodes 26594 time 14 nps 1833362 pv a5a7 e8d8 e4d5 d8c8 d5d6 c8b8 a7h7 b8c8 d6e7
info depth 10 score cp 696 nodes 42733 time 21 nps 2024990 pv a5a7 e8d8 e4d5 d8c8 d5d6 c8b8 a7h7 b8c8 h7e7 c8d8 e7e6
info depth 11 score cp 703 nodes 66359 time 31 nps 2116468 pv a5a7 e8d8 e4d5 d8c8 d5d6 c8b8 a7c7 b8a8 d6e7 a8b8 e7d8
info depth 12 score cp 704 nodes 110300 time 49 nps 2214449 pv a5a7 e8d8 e4d5 d8e8 d5d6 e8f8 a7e7 f8g8 d6c7 g8f8 c7d8 f8g8
info depth 13 score cp 706 nodes 185298 time 81 nps 2283294 pv a5a7 e8d8 e4d5 d8e8 d5d6 e8f8 a7e7 f8g8 d6c7 g8f8 c7d8 f8g8 e7e6
info depth 14 score cp 705 nodes 509191 time 213 nps 2386096 pv a5a7 e8d8 e4d5 d8c8 d5d6 c8b8 a7c7 b8a8 d6c6 a8b8 c6b6 b8a8 c7c8
info depth 15 score cp 710 nodes 771567 time 324 nps 2379568 pv a5a7 e8d8 e4d5 d8e8 d5d6 e8f8 a7e7 f8g8 d6c7 g8f8 c7d8 f8g8 d8e8 g8h8 e7e6
info depth 16 score cp 9965 nodes 1291718 time 552 nps 2336776 pv a5a7 e8d8 a7g7 d8e8 e4d5 e8f8 g7d7 f8e8 d5e6 e8f8 d7a7 f8g8 e6f6 g8h8 f6g6 h8g8 a7a8
info depth 17 score cp 9969 nodes 1496280 time 665 nps 2249441 pv a5a7 e8d8 a7g7 d8e8 e4d5 e8f8 g7d7 f8g8 d7a7 g8h8 d5e6 h8g8 e6f6 g8h8 f6g6 h8g8 a7a8
www.vanheusden.com: Micah / Embla / PuppetMaster / DeepBrutePos / Pos / Feeks

bob
Posts: 20640
Joined: Mon Feb 27, 2006 6:30 pm
Location: Birmingham, AL

Re: Basic endgames

Post by bob » Sun Sep 22, 2019 11:06 pm

same as my other suggestion. PSQ for losing side hates the edge of the board. Winning side wants to get king close to losing king. The rook will automatically do the right thing to hem the king on the edge of the board and keep it there, thanks to the losing side's PSQ hating the edge. Those two simple things and this will be easy. If you do this right, it will work for the much more difficult KQ vs KR ending as well, with no table bases needed.

bob
Posts: 20640
Joined: Mon Feb 27, 2006 6:30 pm
Location: Birmingham, AL

Re: Basic endgames

Post by bob » Mon Sep 23, 2019 3:02 am

As a note, I just checked the position above. I ran with sd=4 (4 ply max depth) and no endgame tables at all. Crafty forced mate easily. If you don't limit the search to 4 plies it will find a mate in 7 instantly so it needs some help to make it rely just on the PSQ stuff I mentioned. Works well...

Henk
Posts: 5832
Joined: Mon May 27, 2013 8:31 am

Re: Basic endgames

Post by Henk » Fri Sep 27, 2019 12:51 pm

Could be worse but value should be zero and not equal to two pawns.
Looks like a bug in stalemate detection.

[d] 8/8/8/8/8/2k5/7P/4K3 w - -

Code: Select all

Depth  Value   Time           Nodes
   1      97            0              7    e1d1 
   2      94            0             41    e1d1  c3b4 
   3      97            0            223    e1d1  c3d3  h2h4 
   4      94            0           1906    e1e2  c3d4  e2f3  d4c5 
   5     148            0           3397    h2h4  c3b4  h4h5  b4a5  h5h6 
   6     146            0           6872    h2h4  c3b4  h4h5  b4a5  h5h6  a5a6 
   7     207            1          15311    h2h4  c3b4  h4h5  b4a5  h5h6  a5a6  h6h7 
   8     203            3          31243    h2h4  c3d4  h4h5  d4e5  h5h6  e5f6  h6h7  f6g7 
   9     110            9          64417    h2h4  c3d4  h4h5  d4e5  h5h6  e5f6  e1f2  f6g6  h6h7 
  10      93           19         145933    h2h4  c3d4  e1f2  d4e4  f2g3  e4f5  g3f3  f5e5  f3e3  e5f5 
  11      95           42         316952    e1e2  c3d4  e2f3  d4e5  f3g4  e5f6  g4f4  f6g6  f4g3  g6g5  h2h3 
  12      93          100         778532    e1e2  c3d4  e2f2  d4e4  f2g3  e4e5  h2h4  e5f5  g3f3  f5e5  f3e3  e5f5 
  13      94          216        1640488    e1e2  c3d4  e2f3  d4e5  h2h3  e5f5  h3h4  f5f6  f3g4  f6g6  h4h5  g6h6  g4h4 
  14      94          472        3579979    e1e2  c3d4  e2f3  d4e5  f3g4  e5f6  h2h3  f6g6  h3h4  g6h6  h4h5  h6h7  g4g5  h7h8 
  15     153         1125        8034753    e1e2  c3d4  e2f3  d4e5  f3g4  e5f6  h2h3  f6g6  h3h4  g6h6  h4h5  h6h7  g4g5  h7h8  h5h6 
  16     153         2160       15759598    e1e2  c3c4  h2h4  c4d4  e2f3  d4e5  f3g4  e5f6  h4h5  f6g7  g4g5  g7g8  h5h6  g8h7  g5h5  h7g8 
  17     155         5196       37195276    e1e2  c3d4  e2f3  d4e5  f3g4  e5f6  h2h4  f6g6  h4h5  g6h6  g4h4  h6h7  h4g5  h7g7  h5h6  g7h7  g5h5 
  18     153        11061       78090349    e1e2  c3d4  e2f2  d4e4  f2g3  e4e5  h2h3  e5f5  h3h4  f5e5  g3g4  e5e6  g4g5  e6f7  h4h5  f7g7  h5h6  g7h7 
  19     216        25503      177424684    e1e2  c3c4  h2h4  c4d4  e2f3  d4d5  f3f4  d5d6  h4h5  d6e6  f4g5  e6e7  g5g6  e7f8  h5h6  f8g8  h6h7  g8h8  g6h6 
Analysis stopped

Henk
Posts: 5832
Joined: Mon May 27, 2013 8:31 am

Re: Basic endgames

Post by Henk » Fri Sep 27, 2019 1:10 pm


Code: Select all

20    1120        35104      159511091    f4g5  e6d5  h4h5  d5c4  h5h6  c4b3  h6h7  b3a3  h8=Q  a3b4  g5f4  b4a3  f4e4  a3b3  e4e3  b3a2  e3d2  a2b1  h8a8  b1b2 
e6d5?? Something wrong. Enough to do.

Henk
Posts: 5832
Joined: Mon May 27, 2013 8:31 am

Re: Basic endgames

Post by Henk » Thu Oct 03, 2019 10:18 am

Better. There was a bug in my code that returned wrong score when illegal move.
Actually I still don't understand it.

Code: Select all

if (kingCapture != 0)
{
          return ( MATE_SCORE - plyCount + 1, null, 0);
}
was:

Code: Select all

 return (Min(ub, MATE_SCORE - plyCount + 1), null, 0);
Maybe better give an extra boolean back indicating if last move was illegal.
Would be more clear. I don't like code I don't understand.


[d] 4k3/8/8/R7/4K3/8/8/8 w - -

Code: Select all

Depth  Value   Time           Nodes
Analysis stopped
  18      M7       198829       74924534    a5a7  e8d8  e4d4  d8c8  d4d5  c8b8  a7d7  b8a8  d7d8  a8a7  d5c6  a7a6  d8a8 
  17      M7        94907       29906298    a5a7  e8d8  e4d5  d8c8  d5d6  c8b8  a7c7  b8a8  d6c5  a8b8  c5b6  b8a8  c7c8 
  16     582        47277       15546762    e4e5  e8d7  a5b5  d7c6  b5d5  c6b6  e5d6  b6b7  d5a5  b7b6  a5c5  b6a7  d6c6  a7b8  c5a5  b8c8 
  15     582        23401        7452340    e4e5  e8d7  a5d5  d7c6  e5e6  c6b7  d5a5  b7b6  a5e5  b6a6  e6d6  a6b6  e5c5  b6a6  d6c6 
  14     580        11699        3586086    e4e5  e8d7  a5c5  d7e7  c5c7  e7d8  e5d6  d8e8  d6e6  e8f8  c7f7  f8e8  f7d7  e8f8 
  13     581         5745        1640616    e4e5  e8d7  a5a1  d7c6  a1b1  c6c5  b1c1  c5b4  e5d4  b4a3  d4c3  a3a4  c3c4 
  12     579         2875         787201    e4e5  e8d7  a5a1  d7c6  a1b1  c6c5  b1b8  c5c4  e5e4  c4c3  e4e3  c3c4 
  11     581         1418         355766    e4e5  e8d7  a5a1  d7c6  a1b1  c6c5  b1c1  c5b4  e5d4  b4a4  d4c4 
  10     579          708         169948    e4e5  e8d7  a5a1  d7c6  a1b1  c6c5  b1b2  c5c4  e5e4  c4c5 
   9     581          349          75579    e4e5  e8d7  a5a1  d7c6  a1b1  c6c5  b1c1  c5b4  e5d4 
   8     579          174          34695    e4e5  e8d7  a5c5  d7e7  c5c7  e7d8  e5d6  d8e8 
   7     581           86          16456    e4e5  e8d7  a5c5  d7e7  c5c1  e7d7  e5d5 
   6     579           42           5516    a5a8  e8d7  e4d5  d7c7  d5c5  c7d7 
   5     581           21           2076    a5a8  e8d7  e4d5  d7e7  d5e5 
   4     579           10            757    a5a8  e8d7  e4d5  d7e7 
   3     581            5            240    e4e5  e8d7  e5d5 
   2     577            2             82    e4e5  e8d8 
   1     579            2             22    e4e5 
 

Henk
Posts: 5832
Joined: Mon May 27, 2013 8:31 am

Re: Basic endgames

Post by Henk » Thu Oct 03, 2019 10:26 am

Henk wrote:
Fri Sep 27, 2019 1:10 pm

Code: Select all

20    1120        35104      159511091    f4g5  e6d5  h4h5  d5c4  h5h6  c4b3  h6h7  b3a3  h8=Q  a3b4  g5f4  b4a3  f4e4  a3b3  e4e3  b3a2  e3d2  a2b1  h8a8  b1b2 
e6d5?? Something wrong. Enough to do.
Getting this now. Max integer overflow. Even simpel node counting a problem.

Code: Select all

Depth  Value   Time           Nodes
  26      93       335141     -1027607743    f4g5  e6e7  g5g4  e7d6  g4f5  d6e7  f5g5  e7e8  g5h5  e8f7  h5h6  f7g8  h6g6  g8f8  g6f6  f8g8  f6e6  g8g7  e6f5  g7h6  f5f4  h6h5  f4g3  h5g6  g3g4  g6h6 
  25      93       167655     1633830892    f4g5  e6e7  g5g4  e7d6  g4f3  d6d5  f3f2  d5d4  f2f1  d4e4  f1g2  e4d4  g2g1  d4e4  g1h2  e4f4  h2h3  f4f5  h3g3  f5g6  g3g2  g6h5  g2h3  h5h6  h3g4 

Henk
Posts: 5832
Joined: Mon May 27, 2013 8:31 am

Re: Basic endgames

Post by Henk » Thu Oct 03, 2019 10:47 am

Doesn't see checkmate

[d] 8/8/8/4k3/8/8/8/3QK3 w - -

Code: Select all

 17    1119        34494      314287036    d1d7  e5e4  e1f2  e4f4  d7d4  f4f5  d4d6  f5e4  f2f1  e4e3  d6c5  e3d2  c5b4  d2c1  f1e1  c1c2  e1e2 

Post Reply