# Chess engine with GUI

**URL:** <https://fortran-lang.discourse.group/t/chess-engine-with-gui/10774>\
**Category:** Uncategorized\
**Created:** [March 11, 2026, 8:19pm UTC](https://fortran-lang.discourse.group/t/chess-engine-with-gui/10774 "2026-03-11T20:19:40Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Beliavsky](https://avatars.discourse-cdn.com/v4/letter/b/ba8739/32.png) [@Beliavsky](https://fortran-lang.discourse.group/u/Beliavsky)\
**Post date:** [March 11, 2026, 8:19pm UTC](https://fortran-lang.discourse.group/t/chess-engine-with-gui/10774/1 "2026-03-11T20:19:40Z")

</div>

The project [GitHub - Beliavsky/Fortran-Chess: Chess engine in Fortran with configurable opening book and time control · GitHub](https://github.com/Beliavsky/Fortran-Chess) 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.

---

<div class="post-metadata">

**Author:** ![fxm](https://yyz2.discourse-cdn.com/free1/user_avatar/fortran-lang.discourse.group/fxm/32/5726_2.png) [@fxm](https://fortran-lang.discourse.group/u/fxm)\
**Post date:** [March 12, 2026, 12:14am UTC](https://fortran-lang.discourse.group/t/chess-engine-with-gui/10774/2 "2026-03-12T00:14:36Z")

</div>

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](https://github.com/interkosmos/fortran-sdl2) and [raylib](https://github.com/interkosmos/fortran-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.

---

<div class="post-metadata">

**Author:** ![certik](https://yyz2.discourse-cdn.com/free1/user_avatar/fortran-lang.discourse.group/certik/32/4_2.png) [@certik](https://fortran-lang.discourse.group/u/certik)\
**Post date:** [March 12, 2026, 5:28am UTC](https://fortran-lang.discourse.group/t/chess-engine-with-gui/10774/3 "2026-03-12T05:28:19Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Cean](https://avatars.discourse-cdn.com/v4/letter/c/bc8723/32.png) [@Cean](https://fortran-lang.discourse.group/u/Cean)\
**Post date:** [March 14, 2026, 6:30am UTC](https://fortran-lang.discourse.group/t/chess-engine-with-gui/10774/4 "2026-03-14T06:30:37Z")

</div>

Nice code.

Tried to compile it. Have error on this sub.

In notation\_utils.f90:

```auto
    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:

```auto
      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.

---

<div class="post-metadata">

**Author:** ![Beliavsky](https://avatars.discourse-cdn.com/v4/letter/b/ba8739/32.png) [@Beliavsky](https://fortran-lang.discourse.group/u/Beliavsky)\
**Post date:** [March 14, 2026, 8:53am UTC](https://fortran-lang.discourse.group/t/chess-engine-with-gui/10774/5 "2026-03-14T08:53:01Z")

</div>

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