summaryrefslogtreecommitdiff
path: root/src/Mahjong/Hand.hs
diff options
context:
space:
mode:
authorJoe Zhao <ztuowen@gmail.com>2015-08-26 17:19:31 -0600
committerJoe Zhao <ztuowen@gmail.com>2015-08-26 17:19:31 -0600
commite795d3d990937a640a22b15b88eebd2b7beee340 (patch)
treeec367330ae9fa2502d29434c298bb8dad83592ee /src/Mahjong/Hand.hs
downloadhmj-e795d3d990937a640a22b15b88eebd2b7beee340.tar.gz
hmj-e795d3d990937a640a22b15b88eebd2b7beee340.tar.bz2
hmj-e795d3d990937a640a22b15b88eebd2b7beee340.zip
fst commit
Diffstat (limited to 'src/Mahjong/Hand.hs')
-rw-r--r--src/Mahjong/Hand.hs27
1 files changed, 27 insertions, 0 deletions
diff --git a/src/Mahjong/Hand.hs b/src/Mahjong/Hand.hs
new file mode 100644
index 0000000..1d1bb80
--- /dev/null
+++ b/src/Mahjong/Hand.hs
@@ -0,0 +1,27 @@
+module Hand where
+
+import Set
+import Pai
+
+data Hand = Hand {getHand::MSet, getCall::[MSet]}
+
+max2Win = 7
+
+pairs c (h:hs) = (if length (filter (==h) hs) >= c then 1 else 0) + (pairs $ filter (/=h) hs)
+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
+
+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)
+
+parseCol xx@(a:b:c:xs) (t,m,p) =
+ concat []
+parseCol _ r = return r
+
+normal h = cm =
+ where cm = pairs 2 $ filter isCha h
+ cp = (pairs 1 $ filter isCha h) - cm
+