Hong Kong style mahjong in the terminal — play against 3 AI opponents
Project description
HK Mahjong
A terminal-based Hong Kong style mahjong game. Play against 3 AI opponents in your terminal.
Features
- Full Hong Kong mahjong rules (4-player)
- Switchable Unicode/ASCII tile rendering (press
rduring game) - Shanten-based AI opponents
- HK faan scoring with 3-faan minimum
- Special hands: Thirteen Orphans, Nine Gates, Great Dragons/Winds, and more
Installation
pip install .
Usage
# Run with Unicode tiles (default)
hk-mahjong
# Run with ASCII tiles
hk-mahjong --ascii
# Run as module
python -m hk_mahjong
# Reproducible game with seed
hk-mahjong --seed 42
Controls
| Key | Action |
|---|---|
← / → |
Select tile |
Enter |
Confirm discard |
w |
Declare win |
p |
Claim pong |
k |
Claim/declare kong |
c |
Claim chow |
n |
Pass (skip claim) |
r |
Toggle Unicode/ASCII rendering |
q |
Quit |
Scoring (Hong Kong Faan)
Minimum 3 faan required to win. Limit hand = 13 faan.
| Pattern | Faan |
|---|---|
| Dragon Pong | 1 |
| Seat/Prevailing Wind | 1 each |
| Self Drawn | 1 |
| No Flowers | 1 |
| Fully Concealed | 1 |
| All Pongs | 3 |
| Mixed One Suit | 3 |
| Pure One Suit | 7 |
| Thirteen Orphans | 13 (limit) |
| Great Dragons | 13 (limit) |
| Great Winds | 13 (limit) |
| All Honors | 13 (limit) |
| Nine Gates | 13 (limit) |
Development
# Install dev dependencies
pip install -e . pytest ruff mypy
# Run tests
pytest
# Lint
ruff check src/
# Type check
mypy src/
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file hk_mahjong-0.1.0.tar.gz.
File metadata
- Download URL: hk_mahjong-0.1.0.tar.gz
- Upload date:
- Size: 29.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5273b43631858745802eef5ed02129239fcab86fb078e25a817cfd5eec46af71
|
|
| MD5 |
f8e0b1381ddff7f0de60e3e8cb24fff1
|
|
| BLAKE2b-256 |
010a719ee77d27487e3b2c8b569fae0877458952fc55659b9eb562945766554e
|
Provenance
The following attestation bundles were made for hk_mahjong-0.1.0.tar.gz:
Publisher:
publish.yml on aidancorrell/hk-mahjong
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
hk_mahjong-0.1.0.tar.gz -
Subject digest:
5273b43631858745802eef5ed02129239fcab86fb078e25a817cfd5eec46af71 - Sigstore transparency entry: 975898809
- Sigstore integration time:
-
Permalink:
aidancorrell/hk-mahjong@baf80e4a3f2308bec899e508d84156e8b0418dbd -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/aidancorrell
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@baf80e4a3f2308bec899e508d84156e8b0418dbd -
Trigger Event:
release
-
Statement type:
File details
Details for the file hk_mahjong-0.1.0-py3-none-any.whl.
File metadata
- Download URL: hk_mahjong-0.1.0-py3-none-any.whl
- Upload date:
- Size: 32.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2fc0531ddde5acc0e421235bf3ac8604f673a1cb3823492c2b0b860b551d404f
|
|
| MD5 |
dc80b85e856640087b9c5371de0fc950
|
|
| BLAKE2b-256 |
0fa63aca341b6359a62f414b20b7db3b6c78eb8b26b0541b1e79c7301635047a
|
Provenance
The following attestation bundles were made for hk_mahjong-0.1.0-py3-none-any.whl:
Publisher:
publish.yml on aidancorrell/hk-mahjong
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
hk_mahjong-0.1.0-py3-none-any.whl -
Subject digest:
2fc0531ddde5acc0e421235bf3ac8604f673a1cb3823492c2b0b860b551d404f - Sigstore transparency entry: 975898811
- Sigstore integration time:
-
Permalink:
aidancorrell/hk-mahjong@baf80e4a3f2308bec899e508d84156e8b0418dbd -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/aidancorrell
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@baf80e4a3f2308bec899e508d84156e8b0418dbd -
Trigger Event:
release
-
Statement type: