bagaturchess / Bagatur

Java Chess Engine (UCI compatible)
http://bagaturchess.github.io/Bagatur/
Eclipse Public License 2.0
72 stars 18 forks source link

How to promote a rook pawn ? #13

Closed tissatussa closed 10 months ago

tissatussa commented 2 years ago

Position: 8/5n2/8/8/6kp/4K3/8/8 b - - 0 1

position

Black to move. Many engines do NOT seem to find the way to promote the pawn !? They often win this position, but after a (too) long move sequence .. NOTE: this pawn is called a "rook pawn" because it's on the edge of the board, on the rook file.

A decent human chess player knows how to promote the pawn in this position : the Black King should shield the pawn by Kg4-g3-g2 so it can ALWAYS reach h1 and promote. From there the mate is easy (the knight is not needed in any way).

Here are some engine evaluations with MPV 5 :

promote_rookpawn_SF_v14_NNUE


promote_rookpawn_Fire_v8_NN_noMCTS


promote_rookpawn_Bagatur_v2 3

Investigate their variations yourself. After some time (not immediately) the engines "Stockfish v14 NNUE" and "Fire v8 NN no MCTS" find mate in 10, indeed starting with Kg3 .. however Bagatur v2.3 (and many other engines) does not have a clue .. it shows long variations, but they make no sense.

Do you have an explanation ? I'm surprised .. i think any engine should know how to quickly win such simple position, eg. :

solution

AlexBrunetti commented 2 years ago

Actually there's a mate in 11 starting with ...h3 and some engines find it before the mate in 10 with ... g3, so it's OK and it's perfectly playable. What are the many other engines, apart from Bagatur, that don't have a clue?

tissatussa commented 2 years ago

@AlexBrunetti you're right .. i checked again : these strong engines all find a proper way to win this position : SlowChess v2.7 Ethereal v13.35 Critter v1.6a Komodo v13.02 (no) MCTS Berserk v7 NNUE Koivisto v7.2 RubiChess v2.3-dev NNUE Zahak v8 NNUE Xiphos v0.6.1 Pedone v3.1 Seer v2.3.1 NN [...many more]

so, i don't know why i concluded that .. i will not edit my text though .. still it's unclear why Bagatur v2.3 has such MPV 5 list ..

bagaturchess commented 2 years ago

Hi,

now Bagatur has more open issues (8) than closed issues (7) - this is new record! :-)

This is what the dev version gives now at depth 36: info string TO_GUI{Thu Dec 09 19:20:58 EET 2021}>info depth 36 seldepth 127 time 105016 nodes 162320954 nps 1545678 score cp 2368 lowerbound hashfull 20 pv g4h3 e3f4 h3g2 f4f5 h4h3 f5f6 f7d8 f6e7 d8b7 e7d7 b7c5 d7c6 c5a6 c6b5 a6c7 b5b4 c7d5 b4a3 g2g1 a3b3 h3h2 b3b2 d5e3 b2b3 g1g2 b3b4 g2g3 b4c3

I believe this is also wrong move, as the white king can go to F file, right? Or knight's moves can put him back ...

Best regards, Krasimir

tissatussa commented 2 years ago

The black king should gard the rook pawn to promotion by staying on the g-file : the white king can never capture the pawn.

bagaturchess commented 2 years ago

I think, this behavior is not caused by the search (depth reductions/static forward pruning), but by the static evaluation function. It has code, which handles positions without pawns - only pieces and kings - and search for mate by pushing enemy king to the corners of the board a.k.a. https://www.chessprogramming.org/Mop-up_Evaluation PosEval = 4.7 CMD + 1.6 (14 - MD), CMD is the Center Manhattan distance of the losing king and MD the Manhattan distance between both kings. When I disable this code it finds as best moves h4h3 and g4g3. These 2 moves are in top 5 best moves of SF as well. No, this is not true, there are also other moves ... I need more time here ... still static evaluation function is suspected.

bagaturchess commented 2 years ago

Hi! :-) I have tested version 3.0 for this position and the moves it thinks about are f7g5 and g4f5, both are evaluated with more than 1800 cp, which must be winning combinations ... Is this correct?

tissatussa commented 2 years ago

it seems in the position ( 8/5n2/8/8/6kp/4K3/8/8 b - - 0 1 ) 12 moves are possible and StockFish rather quickly finds they are all mate in a few moves :

SF_mates_and_Kg3

for Black to win, the pawn must be promoted .. so, the human approach will be Kg3 to gard the pawn and promote it .. but engines show that many moves lead to mate, not only Kg3 .. so, Nf7-g5 and Kg4-f5 are fine, however Bagatur does not give mate !?

Bagatur_Kg3

bagaturchess commented 10 months ago

Syzygy EGTBs are implemented in the latest versions of Bagatur. This solves most endgames, including the one given above.