Basic utilities for working with Mahjong tiles and games
Author tmthyln
1 Star
Updated Last
1 Year Ago
Started In
January 2022


Documentation Unit Tests Nightly Tests

Basic utilities for representing and working with Mahjong tiles, hands, and decks (works in a similar way to PlayingCards.jl).

To get started, you can install from the Julia General repository in the usual way:

(env) pkg> add MahjongTiles

See the full documentation for more details.



Each of the 42 unique standard tiles is represented as a object. To access an individual tile, you can reference the "symbolic" constants that are exported by the package:

julia> using MahjongTiles

julia> ๐Ÿ€›

julia> ๐Ÿ€ฅ

However, it's hard to type these out without already knowing how to type them, so there are a few convenience functions that can create specific tiles:

julia> using MahjongTiles: character, season, wind, dragon

julia> character(3)

julia> season(4)

julia> wind(2)

julia> dragon(1) == dragon(:red)


Depending on the specific variety of Mahjong being played, a deck is composed of 4 of each tile from the 3 standard "suits", plus 4 of each of the winds, 4 of each of the dragons, and sometimes the 8 flowers/seasons. In the code, these are called TilePiles. The easiest way to create one is to just use the standard constructor:

using MahjongTiles: TilePile

deck = TilePile(:standard)


Again, depending on the specific variety being played, a hand is usually composed of 13+1 or 16+1 tiles from a game deck.

There are also functions to test if hands contain certain arrangements; these are used to count points (for gambling, sure, but also for bragging rights).


There's also a similar project MahjongEnvironment; however, this package differs in

  • more broad scope beyond just reinforcement learning
  • registered
  • supporting different variants of Mahjong in a more general way

Used By Packages

No packages found.