Skip to main content

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 r during 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

Metadata

Release files for hk-mahjong 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for hk-mahjong 0.1.0
File Size Uploaded
hk_mahjong-0.1.0.tar.gz 29.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for hk-mahjong 0.1.0
File Interpreter ABI Platform
hk_mahjong-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 62.1 kB

Release files / hk_mahjong-0.1.0.tar.gz

Download URL hk_mahjong-0.1.0.tar.gz
Size 29.4 kB
Tags Source
SHA-256 checksum
How to use checksums
5273b43631858745802eef5ed02129239fcab86fb078e25a817cfd5eec46af71
BLAKE2b-256 checksum
How to use checksums
010a719ee77d27487e3b2c8b569fae0877458952fc55659b9eb562945766554e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Feb 21, 2026.

Transparency log

Release files / hk_mahjong-0.1.0-py3-none-any.whl

Download URL hk_mahjong-0.1.0-py3-none-any.whl
Size 32.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
2fc0531ddde5acc0e421235bf3ac8604f673a1cb3823492c2b0b860b551d404f
BLAKE2b-256 checksum
How to use checksums
0fa63aca341b6359a62f414b20b7db3b6c78eb8b26b0541b1e79c7301635047a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Feb 21, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page