Riichi Typescript library
Small library to calculate hands and yaku for japanese (riichi) mahjong.
Usage
Install the library using npm install riichi-ts
or yarn add riichi-ts
.
Type definitions for typescript are included in the package.
Tiles definition
Tiles are defined by a single integer number according to the following table:
- Man suit:
0
is 1man, ... 8
is 9man - Pin suit:
9
is 1man, ... 17
is 9man - Sou suit:
18
is 1man, ... 26
is 9man - Honors:
- Winds:
27
is east, ... 30
is north - Dragons:
31
is white, 32
is green, 33
is red
Usage:
import { Riichi } from 'riichi-ts';
const hand = new Riichi(
[10, 10, 10, 11, 11, 12, 12],
[
{ open: true, tiles: [13, 14, 15] },
{ open: true, tiles: [15, 16, 17] },
],
{
bakaze: 27,
jikaze: 28
},
13,
false,
true,
false,
false,
false,
false,
0,
true,
true,
false,
);
hand.disableDoubleyakuman();
hand.disableYaku('yaku name');
hand.disableHairi();
const result = hand.calc();
Full list of yaku names that can be detected:
- menzentsumo
- riichi
- ippatsu
- chankan
- rinshan
- haitei
- houtei
- pinfu
- tanyao
- iipeikou
- own wind east
- own wind south
- own wind west
- own wind north
- round wind east
- round wind south
- round wind west
- round wind north
- haku
- hatsu
- chun
- daburu riichi
- chiitoitsu
- chanta
- ittsu
- sanshoku
- sanshoku doukou
- sankantsu
- toitoi
- sanankou
- shosangen
- honroutou
- ryanpeikou
- junchan
- honitsu
- chinitsu
- renhou
- tenhou
- chihou
- daisangen
- suuankou
- suuankou tanki
- tsuuiisou
- ryuuiisou
- chinroutou
- chuurenpoto
- chuurenpoto 9 sides
- kokushimusou
- kokushimusou 13 sides
- daisuushi
- shosuushi
- suukantsu
- dora
- uradora
- akadora
Credits
Inspired by and partially taken from following repositories:
Testing on real games data
The library was tested against millions of real-life game logs from Tenhou.net phoenix lobby. Though we don't supply these logs in the repo, you can still download it on Tenhou.net and use it for testing.
Please place zip archives with real replay logs into logs
folder. The testing script will travers over all zip files there and will try to parse every replay file found.