Mahjong is one of the most popular games in Asia (not the solitaire style found in Windows 7). There were plenty of Mahjong games out there including online ones from Yahoo or offline ones back in the DOS days!
Just another day I was thinking to myself, how can I write one (excluding the GUI)?
The data modeling part is easy.
The winning and scoring rules are... pattern matching?
The strategic part of the game, such as determining which tile to throw out and when to make the Chow or Pong moves are the most difficult part. How to implement this?
Thanks!
Research:
Read this
http://homepage.mac.com/s_lott/books/python/html/p05/p05c05_mahjongg.html
It might help.
"determining which tile to throw out" is actually pretty straight-forward. Given the discards and the nature of the hand, defining a "ready" hand is a matter of determine which potential sets have the most available (non-discarded, not in-play) tiles.
Each tile belongs to one of several possible patterns (pair, up to 3 chows, pung, kong). It's easy to compute the tiles required to fill the pattern. It's easy to reduce the counts of possible tiles based on what's played and what's exposed. The resulting possible patterns can be ranked. Discards are picked from the most-difficult-to-fill combinations.
[See this http://www.amazon.com/Mah-Jong-Handbook-Play-Score/dp/0804838747]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With