https://github.com/stefansalewski/tiny-chess
Tiny Rust chess game with egui board
https://github.com/stefansalewski/tiny-chess
Last synced: 3 months ago
JSON representation
Tiny Rust chess game with egui board
- Host: GitHub
- URL: https://github.com/stefansalewski/tiny-chess
- Owner: StefanSalewski
- License: mit
- Created: 2024-06-08T09:04:44.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-06-22T10:44:58.000Z (4 months ago)
- Last Synced: 2025-06-23T03:51:12.276Z (4 months ago)
- Language: Rust
- Size: 90.8 KB
- Stars: 1
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Tiny Chess
Rust implementation of the salewski-chess engine, now featuring a straightforward `egui` user interface.

This Rust version of the chess engine has several enhancements and bug fixes compared to the original Nim version, and it eliminates the use of global variables.
### Features
- **User Interface**: The new plain `egui` interface allows you to set time per move, select players, and rotate the board.
- **Game Modes**: Supports human vs. human gameplay and engine auto-play.
- **Move List**: When launched from the terminal, the program can print the move list.
- **Non-blocking UI**: The chess engine runs in a background thread to prevent blocking the GUI.### Background
We initially planned to wait for the new Rust Xilem GUI for an improved interface. However, Xilem is still in a very early stage with limited documentation and examples, which makes it challenging to use.
To test the difficulty of creating GUI programs in Rust, we developed a simple `egui` version. This serves as an example of threading using `spawn` and channels simultaneously.
### AI Assistance
Parts of the user interface were created with the help of AI tools. GPT-4 was used to design the initial board layout and the protocol for the engine's background thread.
### Current Status
The chess engine's functionality has undergone minimal testing so far. Nevertheless, it serves as a compact example of using `egui` with a custom graphic area and background task execution.
### Improvements for version 0.4
The endgame logic has been improved and simplified. In endgame, a problem is to correctly estimate the number of moves to checkmate, and
to do not run into a trap repeating the same moves forever. When using the transposition table, it might occur that not always the shortest path
to checkmate is selected, leading to move repetitions: The engine sees the checkmate, but does not choose the correct shortest path, which can
lead to infinitive loops. We now use a simplified logic for this, which is simple and quite good, but not perfect. This is more a theoretical
restriction -- in an ordinary game the human player will typically not survive to the endgame state, and in most cases the computer managed the endgame quite well.### Future Plans
We might develop a Xilem GUI by the end of this year or extend the current `egui` version. Other Rust GUI toolkits like [iced](https://iced.rs/) and [dioxus](https://dioxuslabs.com/) are also potential options.
### How to Run
```sh
git clone https://github.com/stefansalewski/tiny-chess.git
cd tiny-chess
cargo run --release
```[Text content and layout was optimized by GPT-4]