A riichi mahjong game engine https://libmahjong.realliance.page/libmahjong/
  • C++ 85.2%
  • Rust 6.6%
  • CMake 4.2%
  • Nix 3.5%
  • Shell 0.5%
Find a file
alice Hartley 0d4048acbb
Add Action and Mutate Board via Action (#60)
yayy!

Reviewed-on: #60
Reviewed-by: Chris <chris@noreply.git.realliance.net>
2026-11-24 02:59:57 +00:00
.forgejo Move CI to Forgejo Actions and Realliance Pages (#58) 2026-11-14 03:33:54 +00:00
docs Remove old rules pdf. 2025-04-16 13:36:44 -07:00
extern Compile gtest when building tests with msan. (#56) 2025-09-17 21:49:45 -04:00
src Add Action and Mutate Board via Action (#60) 2026-11-24 02:59:57 +00:00
src_cpp Move cpp src into separate dir, handle Display of tile parsing 2026-11-15 03:16:08 +00:00
tests Move cpp src into separate dir, handle Display of tile parsing 2026-11-15 03:16:08 +00:00
tools Move cpp src into separate dir, handle Display of tile parsing 2026-11-15 03:16:08 +00:00
.clang-format Reflow comments and sort includes in blocks. (#54) 2025-09-15 19:19:28 -07:00
.clang-tidy Move cpp src into separate dir, handle Display of tile parsing 2026-11-15 03:16:08 +00:00
.gitignore Initial Rust Board Types 2026-11-14 11:51:01 -08:00
Cargo.lock Extend Board Models (#59) 2026-11-15 04:44:18 +00:00
Cargo.toml Extend Board Models (#59) 2026-11-15 04:44:18 +00:00
clippy.toml Initial Rust Board Types 2026-11-14 11:51:01 -08:00
CMakeLists.txt Move cpp src into separate dir, handle Display of tile parsing 2026-11-15 03:16:08 +00:00
flake.lock Move cpp src into separate dir, handle Display of tile parsing 2026-11-15 03:16:08 +00:00
flake.nix Move cpp src into separate dir, handle Display of tile parsing 2026-11-15 03:16:08 +00:00
README.md Move cpp src into separate dir, handle Display of tile parsing 2026-11-15 03:16:08 +00:00
rust-toolchain.toml Add Action and Mutate Board via Action (#60) 2026-11-24 02:59:57 +00:00
rustfmt.toml Initial Rust Board Types 2026-11-14 11:51:01 -08:00
shell.nix Move cpp src into separate dir, handle Display of tile parsing 2026-11-15 03:16:08 +00:00

libmahjong

ci

libmahjong is a library for running games of Riichi Mahjong, originally built to power Riichi Royale, and later Gametable. The library uses a state machine to represent the status of the game, and allows for players (whether artificial or real) to interact at appropriate times.

Development

libmahjong is being rewritten in Rust. The Rust crate lives in src/ and builds with Cargo, on the toolchain pinned by rust-toolchain.toml. The original C++ engine lives in src_cpp/ and still builds with CMake, as described below.

With Nix, nix develop opens the Rust shell and nix develop .#cpp opens the C++ one. nix build builds the Rust crate, and nix build .#clang builds the C++ library.

Getting Started

Install the following dependencies:

  • git

  • cmake

  • clang or gcc

Optionally:

  • gtest (For testing support)

  • ctcache (For quicker compilation with clang-tidy enabled)

Clone the repository:

git clone https://git.realliance.net/libmahjong/libmahjong.git

Run the following commands within the project directory:

# Bootstrap CMake Environment
cmake -S . -B build

# CMake project opinions (default)
 * libmahjong_build_tools: whether or not examples should be built (ON)
 * libmahjong_build_tests: whether or not tests should be built (ON)
 * libmahjong_use_clang_utils: whether or not project is compiled with clang-tidy (ON)

# Build Project
cmake --build build

Testing and Documentation

The test suite is located in tests/ and can be run with ctest --test-dir build --output-on-failure

CI runs on Forgejo Actions (.forgejo/workflows/): every pull request into next, and every push to it, builds nix build .#clang and runs the tests with nix build .#tests. Each push to next also builds .#coverage and publishes the report at https://libmahjong.realliance.page/libmahjong/.