Code Monkey home page Code Monkey logo

Comments (9)

zhelyabuzhsky avatar zhelyabuzhsky commented on June 6, 2024

Thank you. I'll fix it soon.

from stockfish.

zhelyabuzhsky avatar zhelyabuzhsky commented on June 6, 2024

I tried your example:

wrong_fen = '3kk3/8/8/8/8/8/8/3KK3 w - - 0 0'
s = Stockfish()
print('stockfish created')

s.set_fen_position(wrong_fen)
print('board position set')
move = s.get_best_move()
print('best move is {}'.format(move))

Output:

stockfish created
board position set
best move is d1c1

But even more problematic is that the call get_best_move doesn't return at all

I can't confirm it

from stockfish.

GabrieleMaurina avatar GabrieleMaurina commented on June 6, 2024

I guess we got different behaviors because we are on different systems. I am on Fedora 32, using Stockfish 10 and Python 3.8.

Anyway, in your case you got a "best move" in return, but I think there should be some exception instead, because the board has 4 kings, hence it is an impossible position.

from stockfish.

zhelyabuzhsky avatar zhelyabuzhsky commented on June 6, 2024

Anyway, in your case you got a "best move" in return, but I think there should be some exception instead, because the board has 4 kings, hence it is an impossible position.

but stockfish engine returns best move, doesn't it?

from stockfish.

GabrieleMaurina avatar GabrieleMaurina commented on June 6, 2024

In my case it doesn't return anything and it hangs forever.

If in your case it returned a move, I don't understand how that would be correct, since there is a forbidden position on the board.

from stockfish.

zhelyabuzhsky avatar zhelyabuzhsky commented on June 6, 2024

Is this test case correct?

#37

from stockfish.

GabrieleMaurina avatar GabrieleMaurina commented on June 6, 2024

I admit I am no expert in chess engines.

However it seems inappropriate to me to expect a move like "d1e2" given a wrong board position. In my opinion, it would be more appropriate if an exception was raised when attempting to set a wrong position.

from stockfish.

zhelyabuzhsky avatar zhelyabuzhsky commented on June 6, 2024

an exception was raised when attempting to set a wrong position

This package is not chess engine, it's only the wrapper for stockfish chess engine

If stockfish dont rise an excpetion for wrong position, I think we should not do it also.

from stockfish.

GabrieleMaurina avatar GabrieleMaurina commented on June 6, 2024

I understand this is a wrapper. Chess engines generally communicate to the user through the UCI, hence they cannot raise exceptions. This wrapper communicates to its users through python, so it would be possible to raise an exception. I understand this is a design choice and you are free to make your own decision.

from stockfish.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.