Mahjong Hand Calculator

How close your hand is, what it is waiting on, and what to throw away.

Runs in your browser Free · no account

Setting the table…

About the Mahjong Hand Calculator converter

Lay out your hand and it will tell you how many tiles from finished you are, exactly which tiles would complete it, and — the question you have every turn — which one to throw away.

The tiles are drawn and the arithmetic done on your own machine. There is no account, no server, and nothing sent anywhere.

How far from finished, and why it is a number

A finished hand is four sets and a pair, a set being three of a kind or three in a row of one suit. Everything else follows from that. The distance is how many tiles you would have to change to get there: nought means you are waiting on your last tile, one means one exchange away, and so on up to six for a hand that is nothing yet.

It is worked out by carving the hand up every way it could go and keeping the best of them. A whole set is worth two towards the total, a pair or two tiles that could grow into a run is worth one, and only five such blocks can ever count, because a hand has exactly five places to put them — four sets and the pair.

The case that catches people out

Five blocks with no pair among them looks one better than it is. If your hand is five partial runs and nothing paired, one of those runs has to be broken up to make the pair, and that costs a turn nobody counts.

The same trap works the other way with a hand that is short of blocks: three sets and a lonely pair is further from finished than it feels, because two of the five places are still completely empty.

Waits, and how many are actually left

When a hand is one tile away, it may be waiting on more than one tile, and players undercount this constantly. Three characters, three more, three more, and then 1p 1p 2p 3p is not waiting on a 1p — it is waiting on 1p or 4p, because the pair can be the 1p 1p with 2p 3p growing either way.

Every tile that would finish the hand is listed, with how many of it nobody has seen. Your own tiles come off that count automatically, and anything you have told it about — tiles discarded on the table — comes off too, because those are exactly as unavailable as the ones in your hand.

Which tile to throw away

Every tile in the hand is tried as a discard and judged on two things in order. First, how far from finished it leaves you, since going backwards is almost never right. Then, among the discards that leave you equally close, how many tiles are still out there that would move you forward.

That second number is the half that gets misjudged. A hand waiting on both ends of a run has eight tiles coming; the same hand waiting on the middle of one has four; a hand waiting on the fourth copy of a tile it already holds three of has one. Two discards can leave you the same distance from finished and differ by a factor of four in how likely you are to get there.

The two hands that break the rule

Seven pairs is seven different pairs and nothing else. Four of a kind does not count as two of them, which is a rule people forget and a distinction the arithmetic has to get right.

Thirteen orphans is one of every terminal and honour — the ones and nines of all three suits, all four winds and all three dragons — with one of them appearing twice. Both are measured alongside the ordinary four-sets-and-a-pair shape, and whichever of the three is closest is the one reported, because that is the one you would actually go for.

Which rules this follows

Distance, waits and discards are the same in every Chinese ruleset — Hong Kong, Chinese Official, the Sichuan games — because they follow from what a finished hand is rather than from how it is paid for. That is what this works out, and it is the part you need on every single turn.

Scoring is not the same across those rulesets, and often not even between two tables in the same city, so nothing here puts a value on a hand. Getting that wrong would be worse than not offering it.

Reading and writing a hand

The shorthand is the one used everywhere online: a run of digits followed by a letter saying what suit they were. So m is characters (萬), p is dots (筒), s is bamboo (條), and z is the honours in the order east, south, west, north, white, green, red.

"123m456m789m1234p" is one two three of characters, four five six of characters, seven eight nine of characters, and one two three four of dots. You can type it or tap the tiles; either way the other updates.

Frequently asked questions

What does the number mean?

How many tiles you would have to change to reach a finished hand. Nought means you are waiting on your last tile, one means one exchange away. It is called shanten, and six is the worst a hand can be.

Does it work for Hong Kong mahjong? Chinese Official? Sichuan?

Yes for all of them. How far from finished you are, what you are waiting on and what to discard are identical across Chinese rulesets, because they come from the shape of a finished hand rather than from the scoring. Only the scoring differs, and this deliberately does not score.

Why does it not tell me what my hand is worth?

Because scoring genuinely differs between rulesets and even between tables. A number that was right for one and wrong for another would be worse than no number, so it is left out rather than guessed at.

What if I have already claimed a set from another player?

Set how many you have claimed and the rest follows — each claimed set is three tiles that are finished and out of the way, so the hand in front of you is three tiles shorter for each one.

Can it count tiles that have been discarded?

Yes. Anything you tell it about is taken off the count of what is left, which is what decides between two discards that otherwise look equal — a wait on tiles that are all gone is not a wait at all.

How is seven pairs handled?

As its own shape, measured alongside the ordinary one, with whichever is closer reported. Four of a kind is not counted as two pairs, which is the rule most implementations get wrong.

Is any of this sent anywhere?

No. The tiles are drawn in the page and the analysis runs there. You can turn the network off and it carries on working.