-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Add the chess plugin which leverages stockfish #1095
base: master
Are you sure you want to change the base?
Conversation
ca8ceb5
to
91376fc
Compare
from stockfish import Stockfish | ||
|
||
|
||
@plugin('chess') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@plugin('chess') | |
@require(native="stockfish") | |
@plugin('chess') |
You can even declare in the plugin, that stockfish binary is required ;)
|
||
|
||
@plugin('chess') | ||
class Chess(): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe add an example of usage in the documentation.
Like:
"""
Docu
"""
fen = jarvis.input("FEN: ") | ||
if (fish.is_fen_valid(fen)): | ||
fish.set_fen_position(fen) | ||
jarvis.say(fish.get_best_move()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should catch ValueError at this line
Moves: a2
['a2']
Some error occurred, please open an issue on github!
Here is error:
Traceback (most recent call last):
File "/data/git/Jarvis/jarviscli/CmdInterpreter.py", line 286, in try_do
do(self, s)
File "/data/git/Jarvis/jarviscli/plugin.py", line 208, in run
self._backend[0](jarvis.get_api(), s)
File "/data/git/Jarvis/jarviscli/plugins/chess.py", line 20, in __call__
fish.set_position(moves.split())
File "/home/phil/git/Jarvis/env/lib/python3.8/site-packages/stockfish/models.py", line 222, in set_position
self.make_moves_from_current_position(moves)
File "/home/phil/git/Jarvis/env/lib/python3.8/site-packages/stockfish/models.py", line 238, in make_moves_from_current_position
raise ValueError(f"Cannot make move: {move}")
ValueError: Cannot make move: a2
Nice |
Add a new plugin named
chess
to generate best moves using stockfish.Note: It requires a
stockfish
binary to be present in the user'sPATH
.