How jordan-diaz-eng/lightweightriichimahjong works
LightweightRiichiMahjong is a C++ riichi mahjong rules engine. Its principal workflow is to initialize and deal a hand, present legal actions, apply player decisions through turn and call windows, and produce a hand result; clients can also inspect redacted event observations. The public model adds hand parsing, shanten/ukeire analysis, and scoring. The README is minimal, so capability detail comes from the sampled engine and model sources; unsampled subsystem wiring is omitted.
Main entry points: Engine.cpp Hand engine · Application.cpp Console example · LegalActions.cpp Legal actions · Score.cpp Hand scoring
Components 16
Hand runtime
- Hand engine
LRMahjong/src/LRMahjong/Engine.cpp - Random generator
LRMahjong/src/LRMahjong/RNG.h - Hand result
LRMahjong/src/LRMahjong/Model/Score.h
Rules and analysis
- Legal actions
LRMahjong/src/LRMahjong/Model/LegalActions.cpp - Rule presets
LRMahjong/src/LRMahjong/Model/Rules.h - Win checking
LRMahjong/src/LRMahjong/Model/WinCheck.cpp - Hand scoring
LRMahjong/src/LRMahjong/Model/Score.cpp - Shanten and ukeire
LRMahjong/src/LRMahjong/Model/Shanten.cpp
State and visibility
- Game state
LRMahjong/src/LRMahjong/Model/GameState.cpp - Player hand
LRMahjong/src/LRMahjong/Model/Player.cpp - Hand operations
LRMahjong/src/LRMahjong/Model/Hand.cpp - Tile model
LRMahjong/src/LRMahjong/Model/Tile.cpp - Event observations
LRMahjong/src/LRMahjong/Model/Observation.cpp
Client interface
- Console example
ConsoleApp/src/Application.cpp - Hand parsing
LRMahjong/src/LRMahjong/Model/HandParse.cpp
Other components
- Library consumer
Connections 21
- Library consumer → Console example: runs example
- Library consumer → Hand engine: uses library
- Console example → Hand engine: starts and steps
- Console example → Legal actions: requests actions
- Console example → Shanten and ukeire: queries waits
- Console example → Hand scoring: requests score
- Console example → Hand parsing: parses hand
- Hand engine → Legal actions: validates action
- Hand engine → Game state: updates state
- Hand engine → Random generator: shuffles wall
- Hand engine → Event observations: records events
- Hand engine → Hand result: sets outcome
- Legal actions → Hand scoring: checks yaku
- Legal actions → Shanten and ukeire: checks readiness
- Legal actions → Win checking: checks wins
- Hand scoring → Win checking: decomposes hand
- Event observations → Shanten and ukeire: reconstructs belief
- Game state → Player hand: holds players
- Player hand → Hand operations: maintains tiles
- Hand operations → Tile model: uses tile counts
- Hand engine → Rule presets: uses rules