0

I have written my own simple chess application in JavaFX with UI and other components. Now I want to integrate Stockfish to my application.

How would I do that?

I have gone through a couple of questions like

Connecting Chess Engine with a Java program

What is the optimal way to use Stockfish programmatically?

but all of them boils to this

  • download Stockfish application
  • run in your PC (or server)
  • use your code to interact with the terminal in your PC

This is all fine, but I want my application to be a standalone application and should be able to run anywhere, i.e Mac, Win or Linux.

How would I achieve this? Downloading all 3 of them would make my application heavy. Is there any way to integrate Stockfish without running another application?

4
  • Honestly, you'd be far better off writing your API using a spring boot server w/ a CSS HTML & TypeScript frontend. Personally, I would do Electron w/ Node.js TS, CSS & HTML. But JavaFX is far from the best tech when trying to plugin 3-party software. Commented 2 days ago
  • @JAYD3V It sounds like they are making a desktop application, and you are suggesting that they build a website instead. JavaFX is perfectly fine to use, and there's no reason that they would be unable to interact with a chess engine from Java. Commented yesterday
  • Where did I say anything about a website. Commented 7 hours ago
  • FYI writing a custom API for JavaFX that communicates with 3rd party software that you want to continuously auto update the environment with, well that is just asking for a mess of a project with a million bugs. And that is if you even manage to finish it. Its anything but fine. Commented 7 hours ago

1 Answer 1

1

Most chess engines are built as standalone applications that adhere to the UCI protocol (or the older WinBoard protocol that is no longer used). The point of this is so that the user interface can be developed independently from the engine. A big benefit of this is that it means that if you write a user interface that is capable of interacting with an engine through the UCI protocol, you can load any UCI-compliant engine into the application. Many chess applications will include Stockfish in their downloads by default, but many will also distribute just the user interface and give the user the ability to specify where the engine is installed.

In general, you would be better off accepting that the engine would be a separate application that your program will interact with. You don't need the user to start the engine themselves or deal with sending commands to the engine. You would write something in the code that would deal with managing the interaction with the engine. But ultimately, running a chess engine will be resource-intensive regardless of whether it's bundled into your application or running as a separate process. So there's not really going to be much benefit for avoiding running it as a separate process, which is the way that engines are intended to be run.

Here's an article that goes through how to interact with a UCI-compliant engine (such as Stockfish) from a Java application. Essentially, your application would start a process to run the engine, and it would use the process's standard input and output streams to send commands to the engine and receive the results. You would then need to implement the code that deals with that interaction, so it would be a good idea to familiarize yourself with the UCI protocol.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.