ianfab / Makruk-Stockfish

strong UCI engine for Makruk (Thai chess, หมากรุก) based on Stockfish; superseded by https://github.com/fairy-stockfish/Fairy-Stockfish
GNU General Public License v3.0
10 stars 12 forks source link

Overestimating (passed) pawns, avoiding promotion #3

Closed ianfab closed 6 years ago

ianfab commented 6 years ago

game posted by @woradet

[Event "Computer Chess Game"]
[Site "WORADET"]
[Date "2018.01.29"]
[Round "-"]
[White "Stockfish 290118 64 (UCI2WB)"]
[Black "Bilis 0.14"]
[Result "1/2-1/2"]
[TimeControl "60+1"]
[Variant "makruk"]
[FEN "8/5n1k/5rm1/PP6/1NM5/1K6/8/6R1 w 0 1"]
[SetUp "1"]

{--------------
. . . . . . . .
. . . . . n . k
. . . . . r m .
P P . . . . . .
. N M . . . . .
. K . . . . . .
. . . . . . . .
. . . . . . R .
white to play
--------------}
1. Nc6 Nd6 2. Rd1 Kh6 3. Kb4 Ne4 4. Md5 Nf2 5. Rd2 Ng4 6. Kc5 Rf1 7. Kb6
Ne3 8. Rd3 Ng2 9. Ka6 Rf6 10. Mc4 Nf4 11. Rd2 Nh5 12. Rd1 Ng3 13. Md5 Ne2
14. Rd2 Nc3 15. Rd3 Ne2 16. Kb6 Mf7 17. Rd2 Nf4 18. Kc7 Me6 19. Me4 Nh5 20.
Rd6 Ng7 21. Kb6 Kg5 22. Rd1 Nh5 23. Kc5 Ng3 24. Rg1 Kf4 25. Md3 Rf5+ 26.
Kb4 Rd5 27. Mc4 Rd6 28. Re1 Md7 29. Ne5 Kf5 30. Nd3 Me6 31. Nc5 Nh5 32.
Rf1+ Kg4 33. Nd3 Ng3 34. Ne5+ Kh3 35. Rf6 Ne4 36. Rf4 Ng3 37. Rf6 Ne4 38.
Rf4 Ng3 39. Kc5 Rd8 40. Nc6 Re8 41. Ne5 Rd8 42. Nf3 Rc8+ 43. Kb4 Md7 44.
Md5 Ne2 45. Rf7 Me8 46. Rf8 Kg3 47. Nd2 Nf4 48. Mc6 Nd3+ 49. Kc3 Nf2 50.
Nf1+ Kg2
{Xboard adjudication: 50-move rule} 1/2-1/2

Should be mainly caused by SCALE_FACTOR_ONEPAWN, but more changes might be necessary to fully address that.

woradet commented 6 years ago

OK Sir.ianfab. If i found bug. I will post report a problem . regard. woradet

woradet commented 6 years ago

I think. Is it possible? problem is Make KXK drawish if counting is enabled. https://github.com/ianfab/Makruk-Stockfish/commit/d782b1f970b0cc5f041f323f5b98a4a73edf69ef

ianfab commented 6 years ago

@woradet Could you please explain a bit more what you mean? https://github.com/ianfab/Makruk-Stockfish/commit/d782b1f970b0cc5f041f323f5b98a4a73edf69ef does not seem to be related to this issue, since the KXK evaluation function is only used if the weaker side has at most a pawn or a queen left, which is not the case in the above example.

The main issue in the above game is the scale factor for positions where the stronger side only has one pawn left. The stronger side avoids to promote, because it would otherwise be left with only one pawn.

woradet commented 6 years ago

Sorry I mean No attacking sometime of ai. I'm just predicting.

Mstpcst commented 6 years ago

From yours position that Mr.Woradet post. it Special case of Thai technique it call Maemaipiset (Special case) if you like to make it moves correctly you should compile Valuesend of pieces different in this case I suggest write QueenValueEg 401 but KnightValueMg and KnightValueEg it the same equal 800 and engines will know how to zigzag or know how to move better position. Because it only 1 point different it make line of Engine thinking different. Normally it Think 1 captures 2 pieces it good for make the game advancetage. And another case you should try BishopEg 801 and KnightValueMg and KnightValueEg = 800 it will make engine know Autoboard it mean automatic thinking it Advance mode. But Engine must have right Values it will make good games or know Endgame.

Mstpcst

Mstpcst commented 6 years ago

This is PGN that stockfish that I develop from you source code moves likes this from Mr.Woradet post.

[Event "Local Event"] [Site "Local Site"] [Date "2018.02.01"] [Round "1"] [White "Stockfish Makruk E55310118 64"] [Black "Stockfish Makruk E55310118 64"] [Result "1-0"] [Variant "Makruk"] [SetUp "1"] [FEN "2r1mR2/8/2M5/PP6/8/2K5/5nk1/5N2 w - - 0 1"] [PlyCount "91"]

  1. Ne3+ Kg1 2. Rg8+ Kh1 3. Nc4 Ra8 4. Kd4 Kh2 5. Kc5 Nd3+ 6. Kd6 Nc1 7. Md7 Nb3
  2. Rxe8 Nxa5 9. Rxa8 Nxc4+ 10. Kc5 Ne5 11. Me6 Kg3 12. Kd4 Nd7 13. Md5 Kf4 14. Ra1 Kg5 15. Rf1 Nf6 16. Rg1+ Kf5 17. Rf1+ Kg5 18. Mc6 Nd7 19. Kd5 Kg4 20. Kd6 Ne5 21. Md5 Kg3 22. Kc5 Nd3+ 23. Kd4 Nf2 24. Re1 Ne4 25. Rg1+ Kf3 26. Rg6 Nf6
  3. Mc4 Nd7 28. Re6 Kf4 29. Kc3 Nf6 30. Kb4 Ne4 31. Rh6 Ke5 32. Rh5+ Kd6 33. Rh6+ Kc7 34. Rc6+ Kb7 35. Rh6 Nd6 36. Rxd6 Kc8 37. Rd2 Kb7 38. Rd6 Kc8 39. Md5 Kb7 40. Rc6 Kb8 41. Mc4 Kb7 42. Ka5 Ka7 43. Rc7+ Ka8 44. Kb6 Kb8 45. Rc6 Ka8
  4. Rc8# 1-0
ianfab commented 6 years ago

@Mstpcst If you think you found an improvement to the code, it would be nice if you could run a match between the current and your version to check whether the change improves playing strength.

Mstpcst commented 6 years ago

OK and now my friend make stockfish run in win board I will try more it better than pychess but the code of KBQK it important and autoboard I will tell you more.

ianfab commented 6 years ago

I pushed https://github.com/ianfab/Makruk-Stockfish/commit/e8189ecc535ec45ea5fac89164cfe7aa73d1a601, which includes changes of the endgame code and the passed pawn evaluation. It should remove some artifacts in evaluation and play. Testing and feedback is very welcome.

woradet commented 6 years ago

Thank you sir.ianfab For your develop. for case KNQK , program must know if it move to the same conner that queen square it will checkmate but if it move to another conner that opposite queen attack it mean draw.

normaly only 20 percent it checkmate by wrong move king to the same conner of Queen opposite side. I hope you understand what I mean. Many Thanks

ianfab commented 6 years ago

@woradet There is no heuristic implemented yet for the KNQK endgame (all positions are evaluated as draw there), so it is no surprise that it might blunder in that endgame. The pull request #5 proposes a possible implementation to fix that, but the evaluation of this PR would need some correction as the endgame KNQK can only be won if the king is already close to the right corner.

ianfab commented 6 years ago

@woradet With the current version, I do not observe any more issues with Stockfish avoiding pawn promotion. If you can still reproduce such issues, please let me know, otherwise I will close this issue,

woradet commented 6 years ago

It's OK.Sir Thank you very much

ianfab commented 6 years ago

Ok, thanks.