Talk:Shanten: Difference between revisions

1,093 bytes added ,  14 December 2021
(Created page with "==Articles== * http://blog.ezyang.com/2014/04/calculating-shanten-in-mahjong/ ~~~~")
 
 
Line 1: Line 1:
==Articles==
==Articles==
* http://blog.ezyang.com/2014/04/calculating-shanten-in-mahjong/ [[User:KyuuAA|KyuuAA]] ([[User_talk:KyuuAA|Talk:キュウ]]) 17:28, 7 August 2019 (UTC)
* http://blog.ezyang.com/2014/04/calculating-shanten-in-mahjong/ [[User:KyuuAA|KyuuAA]] ([[User_talk:KyuuAA|Talk:キュウ]]) 17:28, 7 August 2019 (UTC)
== Possible error in accurate shanten formula ==
The wiki reports this formula (ignoring the calculations for chiitoitsu and kokushi musou):
<nowiki>accurateShanten = 8 - 2 * groups - max(pairs + taatsu, floor(hand.length/3)-groups) - min(1, max(0, pairs + taatsu - (4 - groups)))).</nowiki>
Let's try to plug in values for a complete regular hand (14 tiles: 4 groups and 1 pair):
<nowiki>
accurateShanten = 8 - 2 * 4 - max(1 + 0, 4 - 4) - min(1, max(0, 1 + 0 - (4 - 4))) =
                        8 - 8 - 1 - 1 =
                        -2
</nowiki>
But -2 makes no sense! I think the correct formula should replace max with min:
<nowiki>accurateShanten = 8 - 2 * groups - min(pairs + taatsu, floor(hand.length/3)-groups) - min(1, max(0, pairs + taatsu - (4 - groups)))).</nowiki>
Now the result is -1 as expected:
<nowiki>
accurateShanten = 8 - 2 * 4 - min(1 + 0, 4 - 4) - min(1, max(0, 1 + 0 - (4 - 4))) =
                        8 - 8 - 0 - 1 =
                        -1
</nowiki>
Let me know if this makes sense. I hope I got right the meaning of the original formula.