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

Prevent potential errors with the SF process, and misc. #80

Conversation

johndoknjas
Copy link
Contributor

@johndoknjas johndoknjas commented Jan 1, 2022

This PR has a number of small things:

  • If the user calls the __del__ method themselves, this could potentially result in an error, since the OS may call __del__ later. So in each call to __del__, ensure that self._stockfish is still running (i.e., = None).
  • A check is also implemented in the _put function, such that if self._stockfish isn't running, or if the "quit" command has already been sent to Stockfish, then the stdin.write() and stdin.flush() lines won't be executed.
  • Renamed the self.stockfish instance variable to self._stockfish, in order to indicate that it should be treated as private.
  • Changed the default search depth from 2 to 15, in case the user doesn't set it themselves. 15 is a good depth value since it's nearly instantaneous while still being fairly strong.
  • Added to the example in the readme for creating a Stockfish instance, in order to show how to send all the optional arguments together.

@johndoknjas johndoknjas marked this pull request as draft January 1, 2022 10:09
@johndoknjas johndoknjas marked this pull request as ready for review January 1, 2022 10:09
@johndoknjas johndoknjas force-pushed the prevent-potential-errors-with-sf-process-and-misc branch from 4bdc8bf to 95c8927 Compare January 1, 2022 10:26
@johndoknjas johndoknjas force-pushed the prevent-potential-errors-with-sf-process-and-misc branch from 95c8927 to 844c669 Compare January 1, 2022 11:46
@johndoknjas johndoknjas marked this pull request as draft January 1, 2022 15:12
@johndoknjas johndoknjas force-pushed the prevent-potential-errors-with-sf-process-and-misc branch from 9a3fb45 to 92d90df Compare January 1, 2022 19:57
@johndoknjas johndoknjas marked this pull request as ready for review January 1, 2022 20:02
@zhelyabuzhsky zhelyabuzhsky self-requested a review January 2, 2022 04:35
Copy link
Owner

@zhelyabuzhsky zhelyabuzhsky left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good job 👍🏻

@zhelyabuzhsky zhelyabuzhsky merged commit 4ddbf3e into zhelyabuzhsky:master Jan 2, 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