4

I am looking for a way to have my C++ program communicate with Stockfish. An ideal solution would use the compiled version and my program would send commands to the .exe which would return the results. I have looked extensively and have come across suggestions for pipes or the use of the system function but I am not sure how either of those work and if it's possible to have information returned to my C++ program. I am running on Windows. Any suggestions on what method to use and direction on how to apply that method would be greatly appreciated.

1 Answer 1

5

The code required for this is platform dependent, so it may be pragmatic to use a third party API to handle inter-process communication for you. Boost provides Boost.Process and Qt provides QtProcess, both of which allow for communication via stdin and stdout.

Otherwise, you will have to directly interact with platform specific APIs, such as CreateProcess on Windows and fork, pipe, etc. on Linux.

Once you are able to communicate with the engine, you just need to follow the UCI Protocol (which is used by Stockfish) to communicate with the engine.

2
  • Are these methods how most GUI interact with stockfish? Commented Oct 16, 2019 at 15:47
  • 1
    CuteChess, for example, uses the Windows API to interact with engines on windows and QtProcess on other operating systems.
    – konsolas
    Commented Oct 16, 2019 at 15:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.