Note that there are some explanatory texts on larger screens.

plurals
  1. POMahjong winning hand algorithm
    primarykey
    data
    text
    <p>I'm looking for an algorithm that will determine if the current mahjong hand is a winning one. If you are not familiar with the game, here's the basic idea (simplified):</p> <blockquote> <ul> <li>There are three suits of tiles, each containing tiles ranked 1-9. There are also special tiles, seven types of them. Each tile exists in four copies, so there are 36 tiles of each suit and 28 special tiles.</li> <li>A hand has 14 tiles in it.</li> <li>A <em>chow</em> is a set of three tiles of a single rank in sequence.</li> <li>A <em>pong</em> is a set of three identical tiles.</li> <li>A <em>kong</em> is a set of four identical tiles.</li> <li>A <em>pair</em> is a set of two identical tiles.</li> <li>A winning hand is one in which the tiles form any number of chows, pongs, and/or kongs and one pair.</li> </ul> </blockquote> <p>The hand is sorted by suit and then by rank. My idea is something like this:</p> <ol> <li>Mark all tiles as unvisited and nonwinning.</li> <li>Visit first unvisited tile.</li> <li>Check subsequent tiles until a chow, pong, or a kong is encountered, or until there is no possibility of it. If a combination is completed, mark all participating tiles as visited and winning</li> <li>If all tiles have been visited, check if all of them are winning. If not all tiles have been visited, go to 2.</li> </ol> <p>The problem is that once a tile is a part of a combination is cannot be a member of any other combination, one that might make the hand a winning one.</p> <p>Any ideas for a working algorithm?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload