Scoring Kokushi Musou

This commit is contained in:
Correl Roush 2012-05-08 01:06:00 -04:00
parent 17d8670369
commit 55faf8b96e
2 changed files with 14 additions and 0 deletions

View file

@ -89,6 +89,10 @@ score_hand(#hand{tiles=T, sets=_S}=_H, BaseFu, Limit) ->
_DaiSanGen = case sets:is_subset(sets:from_list([{3, #tile{suit=dragon, value=red}}, {3, #tile{suit=dragon, value=white}}, {3, #tile{suit=dragon, value=green}}]), sets:from_list(find_sets(T))) of
true -> 13;
_ -> 0
end,
_Kokushi_Musou = case (lists:flatten([lists:duplicate(12, 1), [2]]) == lists:sort([C || {C, _T} <- find_sets(T)])) and (not lists:any(fun(#tile{value=V}) -> lists:member(V, lists:seq(2,8)) end, T)) of
true -> 13;
_ -> 0
end
],
score(lists:sum(Fu), lists:sum(Han), Limit).

View file

@ -93,3 +93,13 @@ score_hand_dai_san_gan_test() ->
lists:duplicate(2, #tile{suit=wind, value=north})])
},
?assertEqual(riichi:score_hand(Hand, 30), 8000).
score_hand_kokushi_musou_test() ->
Hand = #hand{
tiles = lists:flatten([
[#tile{suit=S, value=V} || S <- [pin, sou, man], V <- [1,9]], % Terminals
[#tile{suit=wind, value=V} || V <- [east, south, west, north]], % Winds
[#tile{suit=dragon, value=V} || V <- [red, white, green]], % Dragons
[#tile{suit=pin, value=1}]])
},
?assertEqual(riichi:score_hand(Hand, 30), 8000).