-
Notifications
You must be signed in to change notification settings - Fork 56
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
stockfish.info returning mate in 1 in a checkmate position #21
Comments
This doesn't seem to be the case for the library version 3.0.0. In that version, |
Sorry, never mind - bug is still present in 3.0.0. I must have never implemented the functionality correctly... |
Hi, @charlesoblack I wrote test: def test_set_fen_position_mate(self, stockfish):
stockfish.set_fen_position('8/8/8/6pp/8/4k1PP/8/r3K3 w - - 12 53')
assert stockfish.get_best_move() is None
assert stockfish.info == '' I think it's correct behaviour. Do you agree? |
Yes, I think that test displays the intended behavior. |
So ... no bug? Can I close this issue? |
While the test itself passes for me, the current behavior still shows up when running through a game with a class TestVisitor(chess.pgn.BaseVisitor):
def __init__(self, gm):
self.gm = gm
self.gm.evals = []
self.move_count = 1
def visit_board(self, board):
self.move_count += 1
sf.set_fen_position(board.fen())
best_move = sf.get_best_move()
print(best_move, sf.info)
info_string = sf.info
rating_match = re.search(r'score (cp|mate) (.+?)(?: |$)', info_string)
if rating_match.group(1) == 'mate':
original_rating = int(rating_match.group(2))
if original_rating:
rating = 9999 * original_rating / abs(original_rating)
elif self.gm.headers['Result'] == '1-0':
rating = 9999
else:
rating = -9999
else:
rating = int(rating_match.group(2))
if board.turn == chess.BLACK:
rating *= -1
self.gm.evals.append(rating) output ends with:
Here is the PGN I am using for the above:
and to run the visitor: vis = TestVisitor(game)
game.accept(vis) |
Additionally, running the test after allowing the visitor to run over the chess game yields the incorrect behavior. |
Can you write test (pull request) to reproduce this bug? |
Created the test in #22 . Now to find out how to fix this bug... |
Thank you I'll try to help you =) |
What about #23? |
I am thinking it might be better to add it in get_best_move as well... I'm
not sure if calling different depths gives different results there. I'll
try and write a test for this too.
|
Ok, I'll merge this pr. If you have a idea to improve this, I will always be glad your PR =) |
Sorry, I've been busy with school :P will let you know when I've thought about this more. Thanks for merging the test :) |
* Update some parameters to be of type bool rather than string. * Fix bug related to stockfish needing lowercase 'false' and 'true' options. * Add some backwards compatability safety checks in models.py, for the new bool types of the three params. Also update the README and .gitignore. * Add docs for simpler way to call get_parameters. * Do a different method for handling the get_parameters change. Instead, deprecate it in favour of a new function. * Update some wording in the readme. * Small edits to docs for recent changes. * Update test function Co-authored-by: kieferro <[email protected]> --------- Co-authored-by: kieferro <[email protected]>
Example code:
The position in the FEN is checkmate, but info string returns a mate in 1:
'info depth 10 seldepth 2 multipv 1 score mate 1 nodes 204 nps 204000 tbhits 0 time 1 pv a2a1'
The FEN position is the last position in this game.
The text was updated successfully, but these errors were encountered: