stnevans / Apollo

Uci Compatible Chess Engine.
GNU General Public License v3.0
8 stars 1 forks source link

Illegal moves fix and other improvements #9

Closed En-En-Code closed 1 year ago

En-En-Code commented 1 year ago

The two illegal moves in #8 (against TSCP and the first against EnkoChess) have been resolved. An oversight in move generation caused Apollo to not see an en passant capture as a valid way to leave check, causing the last move of the position command to not be recognized and Apollo to think it was playing the opposite side of the board.

Although I could not replicate the second illegal move against EnkoChess, I could replicate Apollo fumbling its way through winning endgames (especially KRvK). With some changes to how the mate score is returned from the evaluation function and how it is stored and retrieved in the transposition tables, Apollo should no later attempt such circuitous routes to mating.

Some other minor issues were touched on. Illegal moves should occur far less frequently in PV output (although they still show up occasionally). An issue with De Morgan's Law was fixed in FEN string creation. Also, the engine no longer stalls and/or disconnects at plies 319 and beyond. There are still time management issues, unfortunately. Finally, I found a way to push back calling Eval::evaluate until after looking through the transposition table, which speeds up iterative deepening quite nicely.

I ran 60 game pairs (4-ply book, 40 moves/1 minute) to compare versions. PGN of the games

Apollo v 1.2.1-bug-fixes-3409d7d vs Apollo v 1.2.1-master-dc1c9bb: +71=35-14 [73.8%]
Apollo v 1.2.1-bug-fixes-3409d7d playing White: +40=14-6 [78.3%]
Apollo v 1.2.1-bug-fixes-3409d7d playing Black: +31=21-8  [69.2%]
Apollo v 1.2.1-bug-fixes-3409d7d results:
 - Win by checkmate: 65
 - Win by opponent making illegal move: 4
 - Win by opponent losing connection: 1
 - Win by opponent losing on time: 1
 - Draw by 3-fold: 17
 - Draw by adjudication: 13
 - Draw by insufficient material: 5
 - Loss by checkmate: 11
 - Loss by losing on time: 3
Elo difference: 179.5 +/- 56.5, Draw Ratio: 29.2%

Do I think these fixes gained 180 ELO? No. I estimated they gained closer to 60. Considering there are a lot of TODOs still in the code and some pesky loses on time and illegal pv moves, there is still plenty of work to do. However, this is significant enough progress that I think it is worth making the pull request here.

stnevans commented 1 year ago

Wow, awesome! Seems like there are still some issues to be addressed, but you did a great job. I'll merge this.