The checkmate eval is returning None which causes a lot of downstream problems. This isn't usually a problem because a checkmate only happens in a mate-in-1 position, so the eval from a previous position that is examined carries forward to the checkmate position, but if said mate-in-1 position is skipped in the eval analysis, this leads to errors estimating win probabilities.
This PR fixes this by checking whether the position is checkmate and returning 9999 / -9999 depending on the winner. As a result, get_sf_evaluation never returns None, so I cleaned up some code and made it a little more straightforward.
Finally, I added a test for a checkmate position so that this error hopefully does not happen again.
The checkmate eval is returning
None
which causes a lot of downstream problems. This isn't usually a problem because a checkmate only happens in a mate-in-1 position, so the eval from a previous position that is examined carries forward to the checkmate position, but if said mate-in-1 position is skipped in the eval analysis, this leads to errors estimating win probabilities.This PR fixes this by checking whether the position is checkmate and returning 9999 / -9999 depending on the winner. As a result,
get_sf_evaluation
never returnsNone
, so I cleaned up some code and made it a little more straightforward.Finally, I added a test for a checkmate position so that this error hopefully does not happen again.