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

Add the chess plugin which leverages stockfish #1095

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

gaganchandan
Copy link

@gaganchandan gaganchandan commented Apr 29, 2023

Add a new plugin named chess to generate best moves using stockfish.

Note: It requires a stockfish binary to be present in the user's PATH.

@gaganchandan gaganchandan force-pushed the chess branch 2 times, most recently from ca8ceb5 to 91376fc Compare April 29, 2023 08:01
@gaganchandan gaganchandan changed the title Added the chess plugin which leverages stockfish Add the chess plugin which leverages stockfish Apr 29, 2023
from stockfish import Stockfish


@plugin('chess')
Copy link
Collaborator

@pnhofmann pnhofmann May 14, 2023

Choose a reason for hiding this comment

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

Suggested change
@plugin('chess')
@require(native="stockfish")
@plugin('chess')

You can even declare in the plugin, that stockfish binary is required ;)



@plugin('chess')
class Chess():
Copy link
Collaborator

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())
Copy link
Collaborator

@pnhofmann pnhofmann May 14, 2023

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

@pnhofmann
Copy link
Collaborator

Nice

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