iamjarret / pystockfish

Implements an easy-to-use Engine class to integrates the Stockfish chess engine with Python
GNU General Public License v3.0
30 stars 13 forks source link

Doesn't work with variant FENs? #6

Open DeFilippis opened 9 years ago

DeFilippis commented 9 years ago

Hey Jarret,

If I run stockfish from the command line on a traditionally illegal FEN like so:

position pppppppp/pppppppp/pppppppp/ppppp1pp/1pp1ppp1/8/PPPP1PPP/RNBQKBNR w KQkq - 0 2
go

Stockfish will work with it and yield a move choice. However, if I do the same with your Python wrapper (which is excellent, by the way) like this

deep = Engine()
deep.setfenposition("pppppppp/pppppppp/pppppppp/ppppp1pp/1pp1ppp1/8/PPPP1PPP/RNBQKBNR w KQkq - 0 2")
print deep.bestmove()

The engine hangs indefinitely. Any ideas on how to fix this?

iamjarret commented 9 years ago

Hi Evan,

Thanks for the nice feedback! Here's one idea:

try running

engine.put("position pppppppp/pppppppp/pppppppp/ ppppp1pp/1pp1ppp1/8/PPPP1PPP/RNBQKBNR w KQkq - 0 2")

does it work? If so, then your version of stockfish is using a different UCI protocol. Change line 183 to remove the word "fen." Otherwise, try running engine.isready(). If that freezes there is a problem reading stockfish's output and I'd have to get back to you with a solution.

On Thu, Apr 9, 2015 at 10:55 AM, Evan DeFilippis notifications@github.com wrote:

Hey Jarret,

If I run stockfish from the command line on a traditionally illegal FEN like so:

position pppppppp/pppppppp/pppppppp/ppppp1pp/1pp1ppp1/8/PPPP1PPP/RNBQKBNR w KQkq - 0 2 go

Stockfish will work with it and yield a move choice. However, if I do the same with your Python wrapper (which is excellent, by the way) like this

deep = Engine() deep.setfenposition("pppppppp/pppppppp/pppppppp/ppppp1pp/1pp1ppp1/8/PPPP1PPP/RNBQKBNR w KQkq - 0 2") print deep.bestmove()

The engine hangs indefinitely. Any ideas on how to fix this?

— Reply to this email directly or view it on GitHub https://github.com/iamjarret/pystockfish/issues/6.

Jarret Petrillo iamjarret.github.io 908-451-8373

DeFilippis commented 9 years ago

Hey Jarret,

Thanks! I had to manually do the work with "engine.put", and it worked. Thanks!

iamjarret commented 9 years ago

Great! You may have an old version of Stockfish installed.

On Thu, Apr 9, 2015 at 12:30 PM, Evan DeFilippis notifications@github.com wrote:

Hey Jarret,

Thanks! I had to manually do the work with "engine.put", and it worked. Thanks!

— Reply to this email directly or view it on GitHub https://github.com/iamjarret/pystockfish/issues/6#issuecomment-91282917.

Jarret Petrillo iamjarret.github.io 908-451-8373