https://github.com/tmthyln/mahjongtiles.jl
Basic utilities for working with Mahjong tiles and games
https://github.com/tmthyln/mahjongtiles.jl
games julia mahjong
Last synced: over 1 year ago
JSON representation
Basic utilities for working with Mahjong tiles and games
- Host: GitHub
- URL: https://github.com/tmthyln/mahjongtiles.jl
- Owner: tmthyln
- License: mit
- Created: 2022-01-24T03:12:09.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2022-12-25T05:53:52.000Z (over 3 years ago)
- Last Synced: 2025-01-20T19:56:58.321Z (over 1 year ago)
- Topics: games, julia, mahjong
- Language: Julia
- Homepage: https://tmthyln.github.io/MahjongTiles.jl/latest/
- Size: 354 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# MahjongTiles.jl
[](https://github.com/tmthyln/MahjongTiles.jl/actions/workflows/docs.yml)
[](https://github.com/tmthyln/MahjongTiles.jl/actions/workflows/tests.yml)
[](https://github.com/tmthyln/MahjongTiles.jl/actions/workflows/nightly.yml)
Basic utilities for representing and working with Mahjong tiles, hands, and decks
(works in a similar way to
[PlayingCards.jl](https://juliahub.com/ui/Packages/PlayingCards/I6MLG/0.3.0)).
To get started, you can install from the Julia General repository in the usual way:
```julia
(env) pkg> add MahjongTiles
```
See the [full documentation](https://tmthyln.github.io/MahjongTiles.jl/latest/) for more details.
## Components
### Tiles
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
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
julia> using MahjongTiles: character, season, wind, dragon
julia> character(3)
🀉
julia> season(4)
🀩
julia> wind(2)
🀁
julia> dragon(1) == dragon(:red)
🀄
```
### Decks
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 `TilePile`s.
The easiest way to create one is to just use the standard constructor:
```julia
using MahjongTiles: TilePile
deck = TilePile(:standard)
```
### Hands
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).
## Related
There's also a similar project [MahjongEnvironment](https://github.com/coldinjection/MahjongEnvironment);
however, this package differs in
- more broad scope beyond just reinforcement learning
- registered
- supporting different variants of Mahjong in a more general way