Description
Changelog
Reviews (0)

GDRiichiMahjong is a riichi (Japanese) mahjong rules library for Godot 4, written in pure GDScript. It has no C# or GDExtension parts, so it works the same on every export platform, including Web and mobile.

It is a port of the Python library MahjongRepository/mahjong 2.3.0 (MIT), whose authors report validating it on more than 26 million four-player winning hands from tenhou.net. This port is compared with the original on more than 20,000 test cases.

Features

  • Tiles: MPSZ strings such as "123m406p789s11z", 34-tile count arrays and 136-tile ID arrays, with red fives and dora indicators.
  • Shanten: regular hands, seven pairs and thirteen orphans, with open melds and three-player rules.
  • Waits and discards: winning tiles, tile acceptance with the number of tiles left, and the best discard for a 14-tile hand.
  • Hand value: yaku, han, fu and points. All 63 yaku of the original library are supported, including dora, red fives, ura dora and optional local yaku.
  • Rule options: open tanyao, double yakuman, kiriage mangan, kazoe yakuman limits, aotenjou and more.
  • English and Japanese yaku names.

Usage

Every script has a class_name, so there is no plugin to enable.

var hand := RiichiTiles.mpsz_to_34("123m456p789s1122z") RiichiShanten.calculate(hand) # 0 = tenpai RiichiWaits.get_waits(hand) # [27, 28] = 1z, 2z var tiles := RiichiTiles.mpsz_to_136("123m456p234789s55p") var config := RiichiHandConfig.from_dict({ "is_riichi": true, "is_tsumo": true, "player_wind": RiichiTiles.EAST, "round_wind": RiichiTiles.EAST, }) var r := RiichiHandCalculator.estimate_hand_value(tiles, tiles[3], [], PackedInt32Array(), config) # r.han == 3, r.fu == 20, r.cost.total == 3900 # yaku: Menzen Tsumo, Riichi, Pinfu

More examples are in addons/riichi_mahjong/examples/basic_usage.gd.

Compatibility

Godot 4.2 or later. Tested on 4.2.2, 4.3, 4.4.1, 4.5.2, 4.6.3 and 4.7.2.

Changelog for version 0.2.0

2026-11-27 22:54:00

No changelog provided for this version.

Reviews

GDRiichiMahjong has no reviews yet.

Login to write a review.

Consider supporting the creators!

If you enjoyed this asset consider supporting its creator. Follow the link below.