Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Illegal moves fix and other improvements #9

Merged
merged 3 commits into from
Nov 15, 2022

Conversation

En-En-Code
Copy link
Contributor

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.

FIX: Engine stalling/disconnecting around ply 320

FIX: En passant capture of a checking pawn not considered legal

FIX: Corrected extraneous - appearing in FEN castle field
The TT reads updating the PV reduces illegal moves cropping up in the pv. Also not calling Eval::evaluate until after checking the TT should provide a healthy performance improvement.
@stnevans
Copy link
Owner

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

@stnevans stnevans merged commit 80dc024 into stnevans:master Nov 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants