bsamseth / Goldfish

Goldfish - Stockfish's very distant and not so bright cousin - a UCI chess engine
MIT License
6 stars 2 forks source link

Goldfish v2.0.0 can't win endgame K+R vs K #45

Closed tissatussa closed 2 weeks ago

tissatussa commented 2 weeks ago

it just happened in a 5m+3s game : https://lichess.org/V1mabA1a same bug as #25 ?

bsamseth commented 2 weeks ago

Thanks for reporting! This should be fixed by #46. I'm doing a bit of polishing and testing before the next patch version, which will include this fix. Planning a new version and releasing 2.0 to lichess this week 🤞🏼

tissatussa commented 2 weeks ago

This should be fixed by #46

I will test a new version, i guess this 'erroneous behaviour' can simply be reproduced by letting the engine play any such position. Same for K+Q vs K ? I didn't try. It's really a pity such winning endgame is drawn this way, it shouldn't happen.

It's an 'utter' endgame phase with only one piece left. Sure, TBs exist for that, but i guess simply restricting the movement of the opponent King seems the proper approach. That way K+B+B vs K and even K+N+B vs K could result in a win also. Watch out for K+N+N vs K : many simple engines think it's an easy win, being 2 pieces up, but we know that's a draw .. unless an opponent (!) pawn lives on the g-line or so - a known exception. And don't let the engine give its last pawn too easily, normally a pawn should promote to win.

bsamseth commented 2 weeks ago

I'll be honest and say I'll just rely on a TB for that. It could mean it takes way longer to get to mate, especially things like K+B+NvK, but there's so many edge cases to consider. Hopefully, correct draw detection is enough to avoid losing these won positions.

That said, maybe restricting opponent's king mobility could be a worthwhile move ordering heuristic in the late game. At least for now, I most enjoy optimizing search instead of improving evaluation.

I'll ping this issue once a new release is ready. Again, thanks for testing and reporting!

tissatussa commented 2 weeks ago

I see you quickly created v2.0.1 I compiled that source and the engine plays well in CuteChess GUI. It even made a draw (by repetition!) while being 2 pawns down :

goldfish-v2 0 1-draws

The White King can't approach its pawns, so these can never promote : draw ! Isn't this a nice example of the "Fix draw-by-repetition detection" #42 ?

bsamseth commented 2 weeks ago

I was going to do some manual spot checks before pinging you, but I see you beat me to it! Thanks again 😊 That's a very fitting example, thanks for sharing it!