Skip to main content

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

hk_mahjong-0.1.0.tar.gz (29.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

hk_mahjong-0.1.0-py3-none-any.whl (32.7 kB view details)

Uploaded Python 3

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

Hashes for hk_mahjong-0.1.0.tar.gz
Algorithm Hash digest
SHA256 5273b43631858745802eef5ed02129239fcab86fb078e25a817cfd5eec46af71
MD5 f8e0b1381ddff7f0de60e3e8cb24fff1
BLAKE2b-256 010a719ee77d27487e3b2c8b569fae0877458952fc55659b9eb562945766554e

See more details on using hashes here.

Provenance

The following attestation bundles were made for hk_mahjong-0.1.0.tar.gz:

Publisher: publish.yml on aidancorrell/hk-mahjong

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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

Hashes for hk_mahjong-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 2fc0531ddde5acc0e421235bf3ac8604f673a1cb3823492c2b0b860b551d404f
MD5 dc80b85e856640087b9c5371de0fc950
BLAKE2b-256 0fa63aca341b6359a62f414b20b7db3b6c78eb8b26b0541b1e79c7301635047a

See more details on using hashes here.

Provenance

The following attestation bundles were made for hk_mahjong-0.1.0-py3-none-any.whl:

Publisher: publish.yml on aidancorrell/hk-mahjong

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page