Thanks to visit codestin.com
Credit goes to github.com

Skip to content

StefanSalewski/xilem-chess

Repository files navigation

xilem-chess

A chess interface powered by the Xilem GUI framework for the lightweight Salewski Chess Engine. Chess UI

✨ Overview

xilem-chess is a Rust-based chess GUI built with Xilem, a declarative UI toolkit. It connects to the compact “Salewski chess engine” and displays a clean, responsive chessboard with live engine moves handled through multi-threading and message passing.

Key highlights:

  • Unicode chess piece rendering
  • Play modes for Player vs Engine and Engine vs Engine
  • Adjustable engine move timing
  • Move highlighting for suggestions and last moves
  • A simple (inacurate) chess clock
  • Display of movelist, and option to print the list in the terminal
  • Thread-safe engine communication via Rust’s mpsc channels

🚀 Features

  • ✅ Fully interactive chessboard
  • ✅ Customizable seconds-per-move for the engine
  • ✅ Board rotation toggle
  • ✅ Move list output to the terminal
  • ✅ Responsive board built with Xilem’s flex/grid system
  • ⚠️ Only click-to-move input (no drag-and-drop yet)
  • ⚠️ No save/load or PGN export functionality
  • ❌ Dynamic scaling and window title updates are not yet supported by Xilem

📦 Requirements

  • Rust 1.78+ (2024 edition)
  • Xilem (latest from GitHub)
  • masonry for layout
  • tokio, num-traits, winit for async and platform integration

Chess pieces are drawn using Unicode symbols. Most systems already have suitable fonts, but the Google font Noto Sans Symbols is bundled and used by default (under Google’s copyright). A future update may allow switching to system fonts.


🔧 Build & Run

git clone https://github.com/stefansalewski/xilem-chess.git
cd xilem-chess
RUST_LOG=off cargo run

When launched, the left panel provides game controls; the right displays the interactive board.


🕹️ Controls

Control Action
Engine plays White Enable/disable engine control of white pieces
Engine plays Black Enable/disable engine control of black pieces
Rotate Flip the board’s orientation
New game Reset to starting position
Print movelist Output move history to terminal
Sec/move Adjust engine’s thinking time per move

Moves are made by clicking a piece’s square, then its destination square.


🧠 Internal Design

  • AppState — manages the board, settings, and UI state
  • engine::Game — contains chess rules and logic
  • Threaded messagingtask(...) with mpsc::Receiver<Move> for engine responses
  • engine_to_board(...) — converts engine’s internal state to UI data structures
  • UI layout — composed using Xilem’s grid, button, checkbox, label, etc.

📱 Platform Compatibility

  • ✅ Linux (X11 and Wayland)
  • ✅ Windows (expected to run without issues)
  • ⚠️ macOS (not tested, should work)
  • ⚠️ Android (android_main, experimental)

❗ Known Gaps

  • No dynamic widget scaling or runtime window title changes
  • Missing promotion UI, PGN handling, and drag-and-drop support

🧪 Developer Notes

This UI was inspired by the stopwatch.rs and calc.rs examples from Xilem, as well as the previous egui-based tiny-chess. The focus is on keeping engine logic separate from UI state for maintainability.

Debug mode:

RUST_LOG=debug cargo run

🔄 Alternative Interfaces

The same engine code can be used with:

Older Nim, GTK, and blocking egui versions are now deprecated and will be removed.


📄 License

Copyright © 2015–2032 Dr. Stefan Salewski Licensed under MIT or Apache 2.0 (same as Rust).

Bundled font: Noto Sans Symbols 2 — see Google’s license for details.


About

First Xilem GUI for the tiny salewski chess engine

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages