I am writing a C# 3D chess game in Unity. I am looking for a chess engine that can

  1. Take in an FEN string
  2. Return the best move to make given this FEN
  3. Check if the board given this FEN is in checkmate

Does anyone know of a chess engine that can do this, preferably in C#? I have tried Stockfish and other chess engines, but they all work from the command line. If anyone knows how I can program the game using an engine that works from the command line, that would also work. Thanks!

1 Answer 1


Unfortunately, chess engine doesn't work like what you expect. In particular, there is no such thing as API in the chess engine world. That's because calculating a chess move takes time, and it'll be insane to block your function call until you can get the move.

Chess engine almost always do the works in its own thread or process. You might need to learn how to interact with a thread/process. You'll also need to learn UCI chess protocol. I don't think there is a wrapper for you, but maybe there is just that I don't know.

Stockfish is a C++ engine, so you might need to wrap it with a managed C++ layer for C#. There is a Stockfish port on C#, but it's not as good as the original. However, you don't even need a source code to do your works. You could also take a closed engine such as Houdini.

General steps:

  1. Download a compiled binary (*.exe). It can be anything like Houdini, Komodo or Stockfish. You don't have to compile the source code yourself.
  2. Use Process.Start in C# to start a process of the chess engine
  3. Talk with the child process like here
  4. Try to send a UCI message like this:


The isready UCI command is like pinging the chess engine. You should hear something back if your implementation works. Please take a look at the UCI documentation, you'll find it on Google. Once you know your code works. Try this:


go move time 1000

This gives the engine one second to make a move. You will get something like this:

bestmove e2e4 ponder e7e5

  • I can give you more details if that was confusing at all. Again, thank you for your help! I really appreciate it.
    – Payal
    Jul 1, 2015 at 17:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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