Shanten: Difference between revisions

From Japanese Mahjong Wiki
Jump to navigation Jump to search
m (Fix min() in maximum shanten formula)
(re-organize the shanten counting methods. in particular, explain how we calculate standard/chiitoitsu/kokushi shanten in their own separate sectiond)
Line 1: Line 1:
'''Shanten''' {{kana|向聴}} is the number of tiles needed for reaching [[tenpai]]. It can also be viewed as the minimum number of tile draws or [[naki|tile calls]] required to attain tenpai.
'''Shanten''' {{kana|向聴}} refers to the minimum number of tiles required in order for a hand to reach [[tenpai]]. For example, a hand in 1-shanten ([[iishanten]]) is one tile away from tenpai, and thus two tiles away from winning.  


==Shanten counts==
==Shanten counts==
The lower the shanten count, the closer the hand is to tenpai. Naturally, that is advantageous as far as [[tile efficiency]] is concerned. After all, the sooner the hand gets to tenpai, then the sooner can the hand win.  For every shanten count, the hand needs any needed tile just to reduce that count.
Lower shanten counts are better: the lower the shanten, the closer the hand is to tenpai, and thus the closer the hand is to winning.
 
The maximum shanten a hand can have is 6-shanten, since all hands are 6-shanten or lower for [[chiitoitsu]]. The maximum shanten a hand could be from the standard "4 groups + 1 pair" shape is 8-shanten.


===Iishanten===
===Iishanten===
Line 17: Line 19:
:{{#mjt:457p111m246s1255z}}  Needs: Any {{#mjt:23456789p12345678s125z}} to 2-shanten.
:{{#mjt:457p111m246s1255z}}  Needs: Any {{#mjt:23456789p12345678s125z}} to 2-shanten.


== Open vs closed ==
== Counting shanten ==
{{main|Naki}}
Multiple methods can be used to count a hand's shanten. These can be used to get a quick, ballpark estimate of shanten during a game.
 
=== Lower bound estimate ===
For the standard "4 groups + 1 pair" shape, every "useless" tile (any lone honor tile; number tiles with no neighbors in a +/- 2 interval) must be discarded or grouped in order to reach tenpai. Therefore, the # of useless tiles will be the lower bound for the "4 group + 1 pair" shape. The shanten could be higher, but cannot be lower for the standard winning shape.
 
It is important to note that counting useless tiles does not account for [[chiitoitsu]] or [[kokushi musou]].
 
''minimumShanten'' = ''Useless_tiles''
 
This method is most effective at the start of a game, and less towards the end.
 
=== Basic shanten ===
A hand with 13 disconnected tiles would be 8-shanten from the "4 groups + 1 pair" shape, the furthest you can get from that shape. Drawing a [[taatsu]] or [[pair]] will get you a tile closer to tenpai, thus reducing shanten by 1. Completing a taatsu/pair, thus forming a tile group, will reduce shanten by 1 again (2 total). This results in the following calculation:
 
*Every hand starts at 8-shanten. Each complete group reduces shanten by 2. Each taatsu/pair in hand reduces shanten by 1.
*However, a mahjong hand requires exactly 4 groups. This means the hand's (taatsu + pairs + groups) count is capped at 4. In other words, if a hand would have more than 4 taatsu/pairs/groups, any taatsu/pair past the 4th won't count.
*In addition to 4 groups, the hand requires at least one pair. So, when (taatsu + pairs + groups) > 4, having at least one pair will reduce shanten by 1.


Often, the decision to open the hand rests on the tiles needed and the yaku most conveniently acquired. In addition, the shanten count may play a factor too, especially at 1-shanten where a discarded tile could put the hand into tenpai.
For example, a hand with 6 taatsu and a lone tile is not (8-6=) 2-shanten; it is instead (8-4=) 4-shanten. A hand with 5 taatsu + 1 pair would be 3-shanten.


== Counting shanten ==
Note: A hand may be organized into different sets of groups. The interpretation with the lowest possible shanten is the correct answer. For example, "123456" could be interpreted as 1 complete group + 1 taatsu ("12 + 345 + 6") or 2 complete groups ("123 + 456"). In this case, the latter interpretation is clearly better. With more complex hands, it is less obvious which tiles to remove: it is essential to test every possibility '''or''' skip obvious possibilities.
Multiple methods can be applied to count shanten and to quickly estimate the shanten count. The variable names below are obvious enough, but with the extra precision that a hand or sub-hand that has groups removed will not include pairs with tiles removed.


=== Minimum shanten ===
''basicShanten'' =
Minimum shanten can easily be checked by how many useless tiles are in hand (any single 3 away, plus single word tiles). It is important to remember that seven pairs and kokushi musou will ignore this basic calculation.
    8
    - 2 * ''groups''
    - max(''taatsu'' + ''pairs'', 4 - ''groups'')
    - 1, if at least one pair and (''taatsu'' + ''pairs'' + ''groups'') >= 5


''minimumShanten'' = min(''uselessTiles'', 6 - ''pairs'', 13 - ''diffTerminals'' - max(''terminalPairs'', 1)).
=== Chiitoitsu ===
The shanten for [[chiitoitsu]] is always (6 - pairs). A hand with 6 pairs is tenpai for chiitoitsu, a hand with 5 pairs is 1-shanten, and so on.


This method is most effective at the start of a game, and less towards the end.
chiitoitsuShanten = 6 - ''pairs''


=== Maximum or basic shanten ===
=== Kokushi ===
Maximum shanten can easily be estimated by naïvely removing groups from the hand, then counting pairs, then taatsu. Assuming no pairs are present, the worst shanten count is always 6. Removing different possible groups will lead to different results: the lowest result from the universe of removable groups is the correct result. Taking away 345 from 1123456 is entirely possible in the process but removing 123 and 456 is clearly more optimal. With more complex hands, it is less obvious which tiles to remove: it is essential to test every possibility '''or''' skip obvious possibilities, such as if a quad occurs, it makes sense to check the first set of three, and skip over the rest, continuing from the 4th tile and the following two.
The shanten for [[kokushi musou]] is 13, minus the number of unique terminals/honors, then minus 1 if you have at least one pair. This means a hand with no terminals/honors is 13-shanten from kokushi.


  ''maximumShanten'' = min(8 - 2 * ''groups'' - max(''pairs'' + ''taatsu'', floor(''hand.length''/3)-''groups'') - min(1, max(0, ''pairs'' + ''taatsu'' - (4 - ''groups''))), 6).
  kokushiShanten = 13 - ''unique_terminals'' - max(''terminal_pairs'', 1)


=== Accurate shanten ===
== Accurate shanten formula ==
Accurate shanten uses the maximum formula, and then includes the conditions for seven pairs and kokushi musou.
=== Base formula ===
The accurate shanten formula combines the formulas for standard form, chiitoitsu, and kokushi musou.


  ''accurateShanten'' = min(8 - 2 * ''groups'' - max(''pairs'' + ''taatsu'', floor(''hand.length''/3)-''groups'') - min(1, max(0, ''pairs'' + ''taatsu'' - (4 - ''groups''))), 6 - ''pairs'', 13 - ''diffTerminals'' - max(''terminalPairs'', 1)).
  ''accurateShanten'' = Smaller of:
    * 8 - (2 * ''groups) - max(''pairs'' + ''taatsu'', 4 - ''groups'') - min(1, max(0, ''pairs'' + ''taatsu'' + ''groups'' - 4)
    * 6 - ''pairs''
    * 13 - ''diffTerminals'' - max(''terminalPairs'', 1))


=== Accurate correction (perfect shanten) ===
=== Accurate correction (perfect shanten) ===
Calculating accurate shanten will give a proper result, -1 indicating a complete hand, any strictly positive integer indicating a distance from tenpai. However, when the result is zero, there is a chance that there are no tiles existing that could lead to creating a winning hand. From 34 possible tiles, trying out every tile ''not present in four copies'' should lead either to a complete hand (-1), or a hand that is "still tenpai" (0). A tenpai hand that can't win does not exist, usually because of the need of a 5th copy of a tile. This does not take into account tiles discarded or melded by other players. Only one's hand and one's melds count against this limit.
Calculating shanten with the above formula will give a proper result, where -1 indicates a complete hand, while any positive integer is the distance from tenpai.  
 
However, when the result is 0, there is a chance that there are no existing tiles that could lead to creating a winning hand. If a hand is 0-shanten, but has all 4 copies of its own winning tiles, as in the below example, then it usually does not count as "tenpai" for the purposes of gameplay. (This only accounts for tiles in the hand, not tiles discarded or in other players' hands.)


:{{#mjt:3456p111m}} {{#mjt:3'336'66p}}
:{{#mjt:3456p111m}} {{#mjt:3'336'66p}}

Revision as of 09:52, 6 September 2024

Shanten 「向聴」 refers to the minimum number of tiles required in order for a hand to reach tenpai. For example, a hand in 1-shanten (iishanten) is one tile away from tenpai, and thus two tiles away from winning.

Shanten counts

Lower shanten counts are better: the lower the shanten, the closer the hand is to tenpai, and thus the closer the hand is to winning.

The maximum shanten a hand can have is 6-shanten, since all hands are 6-shanten or lower for chiitoitsu. The maximum shanten a hand could be from the standard "4 groups + 1 pair" shape is 8-shanten.

Iishanten

Example: 1-shanten

Needs: Any to tenpai.

Ryanshanten

Example: 2-shanten

Needs: Any to 1-shanten.

Sanshanten

Example: 3-shanten

Needs: Any to 2-shanten.

Counting shanten

Multiple methods can be used to count a hand's shanten. These can be used to get a quick, ballpark estimate of shanten during a game.

Lower bound estimate

For the standard "4 groups + 1 pair" shape, every "useless" tile (any lone honor tile; number tiles with no neighbors in a +/- 2 interval) must be discarded or grouped in order to reach tenpai. Therefore, the # of useless tiles will be the lower bound for the "4 group + 1 pair" shape. The shanten could be higher, but cannot be lower for the standard winning shape.

It is important to note that counting useless tiles does not account for chiitoitsu or kokushi musou.

minimumShanten = Useless_tiles

This method is most effective at the start of a game, and less towards the end.

Basic shanten

A hand with 13 disconnected tiles would be 8-shanten from the "4 groups + 1 pair" shape, the furthest you can get from that shape. Drawing a taatsu or pair will get you a tile closer to tenpai, thus reducing shanten by 1. Completing a taatsu/pair, thus forming a tile group, will reduce shanten by 1 again (2 total). This results in the following calculation:

  • Every hand starts at 8-shanten. Each complete group reduces shanten by 2. Each taatsu/pair in hand reduces shanten by 1.
  • However, a mahjong hand requires exactly 4 groups. This means the hand's (taatsu + pairs + groups) count is capped at 4. In other words, if a hand would have more than 4 taatsu/pairs/groups, any taatsu/pair past the 4th won't count.
  • In addition to 4 groups, the hand requires at least one pair. So, when (taatsu + pairs + groups) > 4, having at least one pair will reduce shanten by 1.

For example, a hand with 6 taatsu and a lone tile is not (8-6=) 2-shanten; it is instead (8-4=) 4-shanten. A hand with 5 taatsu + 1 pair would be 3-shanten.

Note: A hand may be organized into different sets of groups. The interpretation with the lowest possible shanten is the correct answer. For example, "123456" could be interpreted as 1 complete group + 1 taatsu ("12 + 345 + 6") or 2 complete groups ("123 + 456"). In this case, the latter interpretation is clearly better. With more complex hands, it is less obvious which tiles to remove: it is essential to test every possibility or skip obvious possibilities.

basicShanten =
   8
   - 2 * groups 
   - max(taatsu + pairs, 4 - groups)
   - 1, if at least one pair and (taatsu + pairs + groups) >= 5

Chiitoitsu

The shanten for chiitoitsu is always (6 - pairs). A hand with 6 pairs is tenpai for chiitoitsu, a hand with 5 pairs is 1-shanten, and so on.

chiitoitsuShanten = 6 - pairs

Kokushi

The shanten for kokushi musou is 13, minus the number of unique terminals/honors, then minus 1 if you have at least one pair. This means a hand with no terminals/honors is 13-shanten from kokushi.

kokushiShanten = 13 - unique_terminals - max(terminal_pairs, 1)

Accurate shanten formula

Base formula

The accurate shanten formula combines the formulas for standard form, chiitoitsu, and kokushi musou.

accurateShanten = Smaller of:
   * 8 - (2 * groups) - max(pairs + taatsu, 4 - groups) - min(1, max(0, pairs + taatsu + groups - 4)
   * 6 - pairs
   * 13 - diffTerminals - max(terminalPairs, 1))

Accurate correction (perfect shanten)

Calculating shanten with the above formula will give a proper result, where -1 indicates a complete hand, while any positive integer is the distance from tenpai.

However, when the result is 0, there is a chance that there are no existing tiles that could lead to creating a winning hand. If a hand is 0-shanten, but has all 4 copies of its own winning tiles, as in the below example, then it usually does not count as "tenpai" for the purposes of gameplay. (This only accounts for tiles in the hand, not tiles discarded or in other players' hands.)

If accurateShanten = 0, for all possibilities of tile: keep lowest accurateShanten(hand + tile) value (-1 or 0) and add 1 (for 0 or 1). The hand above, when any other tile is added to it, is never complete. A proper test would never make a 5th copy of 3p or 6p.

External links