A polished, native cross-platform chess game built with Flutter for the UI
and Rust for the engine + AI, connected through
flutter_rust_bridge.
cozy-chess rules adapter.| Path | Contents |
|---|---|
crates/game_core/ |
Shared game-suite primitives: registry, platform seams, suite store, generic search. |
crates/chess_core/ |
Chess module: api, engine, ai, clock, pgn, suite adapter, session, commands. |
crates/chess_core/src/platform.rs |
Compatibility re-exports for suite platform seams (AppDirs, EventSink). |
crates/chess_bridge/ |
flutter_rust_bridge crate. Exposes 15 commands + a single BackendEvent stream. |
flutter/ |
Flutter app (lib/main.dart, controllers, board widget, modals, audio synth). |
flutter/lib/src/rust/ |
Auto-generated Dart bindings (do not hand-edit; regenerated by flutter_rust_bridge_codegen generate). |
flutter_rust_bridge.yaml |
Codegen config. |
rustup, stable channel).PATH.ANDROID_NDK_ROOT).# Regenerate Dart bindings whenever you edit crates/chess_bridge/src/api.rs.
flutter_rust_bridge_codegen generate
# Run the headless workspace tests (engine, AI, session, trait seams).
cargo test --workspace
# Static analysis + Dart unit tests.
cd flutter
flutter pub get
flutter analyze
flutter test
cd flutter
flutter run -d macos # or windows / linux / <ios sim> / <android emulator>
Flutter automatically invokes the Xcode build phase (flutter/macos/Runner/Scripts/build_rust.sh)
which compiles crates/chess_bridge and embeds it into the .app bundle.
crates/game_core provides the suite foundation: a static game registry
(Chess today), generic platform seams, a reusable suite session store, and a
deterministic turn-based alpha-beta search layer. crates/chess_core is the
first game module and keeps the existing Flutter chess API as a compatibility
facade. Chess rules are delegated to cozy-chess behind that facade, while
the public snapshot, PGN, SAN, and UCI behavior remain owned by chess_core.
AI difficulty levels 1-5 all use the compiled-in Rust engine. The engine runs inside the app process on macOS, Windows, Linux, iOS, and Android, so mobile targets do not need executable extraction and desktop targets do not need sidecar binaries.
15 commands + a single BackendEvent broadcast stream. They live in
crates/chess_core/src/api.rs and are exposed to Dart as:
bridgeInit(dataDir) once at startup.Future<...> commands (newGame, makeMove, …, setSettings).subscribeEvents() returning Stream<BackendEvent> carrying
BackendEvent.moveMade, BackendEvent.aiProgress,
BackendEvent.gameOver, BackendEvent.clockTick.cargo test --workspace # Rust unit + integration tests
flutter test # Dart tests
CI runs both jobs plus a Linux desktop smoke build on every push and pull
request. See .github/workflows/ci.yml.