Connect Chess Engine with C++ GUI Program

I want to connect my C++ Program with a Chess Engine in order to have AI for the enemy. In my c++ program-->User will make a move(eg. A2A3)-->I will pass this string to chess engine-->engine will update board-->engine will start AI for calculating enemy move-->Engine will give enemy's move as string(eg A7A6) to my C++ program-->etc

I read that in order for my program to interact with a chess engine I have to start the chess_engine.exe file and exchange commands with it via the Standard Input/Output.

Can you tell me how exactly can my Visual Studio program code start a exe file and exchange commands with it?? Any example?

Thank you in advance.


To do that, you'll need to start a new thread or process with the engine. Typically, you'll do it by starting a new process where the main function of the engine will be starting point of the new process.

Now, you'll have two processes in your application. You GUI application is the parent process whereas the engine itself will be the child process. You'll need to communicate to the engine via the standard chess UCI protocol. You can pipe inputs and output to/from the child process (which is the engine).

Let's say you want to start a new game. You'll issue the following UCI commands:

isready
ucinewgame

Please read the UCI specification carefully. You can get it on Google.

链接地址: http://www.djcxy.com/p/84652.html

上一篇: 面向对象设计的国际象棋引擎

下一篇: 将国际象棋引擎与C ++ GUI程序连接起来