diff options
author | Joe Zhao <ztuowen@gmail.com> | 2015-09-28 16:07:41 -0600 |
---|---|---|
committer | Joe Zhao <ztuowen@gmail.com> | 2015-09-28 16:07:41 -0600 |
commit | 515573665ad2e94cf3aacd045e6a70f3fc637310 (patch) | |
tree | 692ee5ed6e6f008862c6af204e1e5cdc301d334b /src/Mahjong/Hand.hs | |
parent | e795d3d990937a640a22b15b88eebd2b7beee340 (diff) | |
download | hmj-515573665ad2e94cf3aacd045e6a70f3fc637310.tar.gz hmj-515573665ad2e94cf3aacd045e6a70f3fc637310.tar.bz2 hmj-515573665ad2e94cf3aacd045e6a70f3fc637310.zip |
commit from git, default
Diffstat (limited to 'src/Mahjong/Hand.hs')
-rw-r--r-- | src/Mahjong/Hand.hs | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/src/Mahjong/Hand.hs b/src/Mahjong/Hand.hs index 1d1bb80..f58b602 100644 --- a/src/Mahjong/Hand.hs +++ b/src/Mahjong/Hand.hs @@ -2,6 +2,8 @@ module Hand where import Set import Pai +import Data.List (sort) +import Data.Maybe data Hand = Hand {getHand::MSet, getCall::[MSet]} @@ -13,6 +15,17 @@ pairs c [] = 0 seven h = 7 - (pairs 1 h) mosou h = 14 - (pairs 0 h') - (if pairs 1 h' > 0 then 1 else 0) where h' = filter is19 h +normal h = maxmum $ map getSteps $ normal' (0,0,0) (0,0,0) (head orderedPai) $ sort $ h + where getSteps (p,w,m) = --pairs, waits, mianzi + (if p == 0 then 1 else 0) + + (min w' 4)+2*(max 0 (4-w'-m)) + where w' = (+) w $ max 0 (p-1) + +normal' (a,b,c) (p,w,m) cur (h:hs) + | cur == h = normal' (a,b,c+1) (p,w,m) cur hs + | a + b + c < 2 = -- TODO return + | a < 1 = if nextPai' cur == Nothing + then normal' (b,c,0) cur hs costM a b = (sum $ zipWith (snd.sMmin) a b,zipWith (fst.sMmin) a b) sMmin a b = if (a>b) then (a-b,0) else (0,b-a) |