Scoring Suu An Kou

This commit is contained in:
Correl Roush 2012-05-08 01:27:48 -04:00
parent 2fdf7c8240
commit e727679729
2 changed files with 19 additions and 0 deletions

View file

@ -96,6 +96,13 @@ score_hand(#hand{}=Hand, BaseFu, Limit) ->
_ -> 0
end
end,
_Suu_An_Kou = fun(#hand{}=H) ->
Sets = find_sets(H#hand.tiles),
case 4 == length([C || {C, _T} <- Sets, C == 3]) of
true -> 13;
_ -> 0
end
end,
_Kokushi_Musou = fun(#hand{}=H) ->
Sets = find_sets(H#hand.tiles),
Terminals = not lists:any(fun(#tile{value=V}) -> lists:member(V, lists:seq(2,8)) end, H#hand.tiles),

View file

@ -90,6 +90,18 @@ score_hand_dai_san_gan_test() ->
lists:duplicate(3, #tile{suit=dragon, value=white}),
lists:duplicate(3, #tile{suit=dragon, value=green}),
lists:duplicate(3, #tile{suit=wind, value=east}),
[#tile{suit=pin, value=V} || V <- [5,6,7]],
lists:duplicate(2, #tile{suit=wind, value=north})])
},
?assertEqual(riichi:score_hand(Hand, 30), 8000).
score_hand_suu_an_kou_test() ->
Hand = #hand{
tiles = lists:flatten([
lists:duplicate(3, #tile{suit=pin, value=1}),
lists:duplicate(3, #tile{suit=pin, value=4}),
lists:duplicate(3, #tile{suit=sou, value=2}),
lists:duplicate(3, #tile{suit=man, value=8}),
lists:duplicate(2, #tile{suit=wind, value=north})])
},
?assertEqual(riichi:score_hand(Hand, 30), 8000).