Chess engine with GUI

The project GitHub - Beliavsky/Fortran-Chess: Chess engine in Fortran with configurable opening book and time control · GitHub now has in addition to a console interface a Windows GUI displaying the board and allowing moves to be entered in a text box. The engine usually plays well but can play badly in closed positions, a known chess software weakness. I used Codex with ChatGPT 5.4 to build it, and its advice for building a multi-platform GUI was as follows. I have not built GUIs before. Comments?

The layout would be:

  • chess.exe as the console frontend
  • chessgui.exe as the Windows-native Win32 GUI
  • a separate cross-platform GUI target sharing the same engine

The practical recommendation was:

  • keep the chess engine in Fortran
  • keep frontend code separate from engine code
  • build the cross-platform GUI as a thin frontend, most likely in C or C++
  • talk to the engine either through a clean interface or through UCI

For the cross-platform GUI toolkit, the most practical options I mentioned were:

  • SDL2
  • raylib
  • GTK
  • Qt via a wrapper
  • or a small local web frontend

My recommendation was that SDL2 or raylib would be the simplest realistic path if the goal is one GUI that runs on Windows, Linux, and macOS, while preserving the current native Windows GUI.

I think SDL2 and raylib are good and more than sufficient for your purposes. I’ve worked on a few experimental Fortran-based game systems (and maths/physics “sandboxes”) with an SDL2-based GUI that worked well across common platforms. I’m not sure I’d call it a “thin frontend”, but it’s no problem keeping them separate. Raylib may be simpler (and perhaps more suited), but I have less experience with it. Philipp worked on Fortran interface bindings for SDL2 and raylib, which are very convenient. Going through the examples may give you an idea of how well suited they are for what you have in mind.

3 Likes

SDL3 works well, I got things working using their GPU API on Linux, macOS, Windows natively (accelerated) and I used AI to implement the same API in the browser using WebGPU and WASM. So the same C source code runs everywhere at 60 / 120 fps. For the GUI you can then implement your own drawing and some simple immediate-mode GUI on top, or use some existing libraries.

The key is to write your application once using a good platform API that you create and maintain yourself. Then you can have multiple “backends” of this API for all platforms, including even Qt if you wanted. A good API for a GUI is tricky, I personally like immediate mode GUI and the way you implement the API to, for example, run Qt underneath is that you “diff” it from the previous frame, determine the changes and then adjust the Qt GUI accordingly and automatically. I only have a small prototype, but it works super well and it’s extremely simple on the application code.

Nice code.

Tried to compile it. Have error on this sub.

In notation_utils.f90:

    SUBROUTINE write_pgn_file(filename, move_history, num_half_moves, result_text, move_elapsed_ms_history, time_control_tag)

But it is called chess.f90 with more than 6 variables:

      CALL write_pgn_file('games.pgn', move_history, num_half_moves, &
      pgn_result, move_elapsed_ms_history, &
      pgn_time_control_tag, pgn_event_name, &
      pgn_white_name, pgn_black_name)

There are a few other long lines I need to break them.

Sorry, uploaded version was stale. It should work now.