Riichi Mahjong Calculator Via the Terminal
CLI tool that calculates the score of a hand in riichi mahjong.
- Manual mode (Calculator Mode): given han and fu, calculates the score
- Normal mode: given a hand, calculates the score with included yaku and fu

Examples
Calculator Mode
> Dealer: )
)
Normal Mode
note: the winning group has to go last (this is to calculate fu correctly)
> 7
)
)
Using file input
# hands.txt
--tiles 1p 9p 1s 9s 1m 9m rd gd wd Ew Sw Nw WWw -w Ww -p Ew -s Ew
--tiles 11z NNw SSw WWw rrd wwd ggd -w gd -p Ew -s Ew -d Ew Ew
-m 4 30 --ba 3
)
)
)
)
)
)
Json out
in normal mode
yields
and in calculator mode
yields
Notation
Suits
| Type | Notation |
|---|---|
| Man (Characters) | 1m, 2m, 3m, 4m, 5m, 6m, 7m, 8m, 9m |
| Pin (Circles) | 1p, 2p, 3p, 4p, 5p, 6p, 7p, 8p, 9p |
| Sou (Bamboos) | 1s, 2s, 3s, 4s, 5s, 6s, 7s, 8s, 9s |
Honors
| Type | Notation | MPSZ Notation |
|---|---|---|
| Winds | Ew, Sw, Ww, Nw | 1z, 2z, 3z, 4z |
| Dragons | wd, gd, rd | 5z, 6z, 7z |
Special Notation
| Description | Example |
|---|---|
| Open Sets | 234po (an open sequence of 2, 3, 4 in Pin suit) |
| akadora | 0m, 0p, 0s |
- eg: EEEw (triplet of east wind)
- eg: 234m (sequence of 2 3 4 Man)
- eg: 406s (sequence of 4 5 6 Sou with the akadora 5 sou)
- eg: rrrrdo (open quad of red dragon)
- eg: 11s (pair of 1 sou)
- eg: 8m (8 man tile)
Installation
using cargo
cargo install mahc
mahc --version
build from source
git clone https://github.com/DrCheeseFace/mahc
cd mahc
cargo build
./target/debug/mahc --version
from latest release
curl -s https://api.github.com/repos/DrCheeseFace/rusty-riichi-mahjong-calculator/releases/latest | grep "browser_download_url" | cut -d '"' -f 4 | wget -i -
unzip mahc-v1.1.0-x86_64-unknown-linux-gnu.zip -d mahc
cd mahc/x86_64-unknown-linux-gnu/release
./mahc --version
Implemented hand validations as of yet
One Han Yaku
- Tanyao
- Iipeikou
- Yakuhai
- MenzenTsumo
- Pinfu
- Riichi
- Ippatsu
- Haitei
- RinshanKaihou
- Chankan
Two Han Yaku
- DoubleRiichi
- Toitoi
- Ittsuu
- SanshokuDoujun
- Chantaiyao
- Sanankou
- SanshokuDoukou
- Sankantsu
- Honroutou
- Shousangen
- Chiitoitsu
Three Han Yaku
- Honitsu
- JunchanTaiyao
- Ryanpeikou
Six Han Yaku
- Chinitsu
Yakuman
- KazoeYakuman
- KokushiMusou
- KokushiMusou 13 sided wait
- Suuankou
- Suuankou tanki wait
- Daisangen
- Shousuushii
- Daisuushii
- Tsuuiisou
- Daiichishin
- Chinroutou
- Ryuuiisou
- ChuurenPoutou
- ChuurenPoutou 9 sided wait
- Suukantsu
- Tenhou
- Chiihou
TODO
- validation a hand is possible (eg not having 20 east tiles :)
- add all da yaku
- validation on if yaku is there
- validate winning tile
- propogate the errors up for a nice printout
- validate stuff like cant riichi and double riichi. all that haitei, chankan rinshan shizz
- file stdIn
- json out flag
- add more comprehensive tests
- document the undocumented
- tile input for
--doraflag
Contributing
- If you spot a bug (which there probabably are many), put in an issue with how to reproduce it
- if youd like to contribute, DO IT (send a PR)
- keep in mind, we pretty far from finishing it currently. so FUCK validation (for the time being)
