mirror of
https://github.com/correl/riichi.git
synced 2024-11-27 19:19:54 +00:00
Scoring Kokushi Musou
This commit is contained in:
parent
d549089063
commit
7547dcab88
2 changed files with 14 additions and 0 deletions
|
@ -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
|
_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;
|
true -> 13;
|
||||||
_ -> 0
|
_ -> 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
|
end
|
||||||
],
|
],
|
||||||
score(lists:sum(Fu), lists:sum(Han), Limit).
|
score(lists:sum(Fu), lists:sum(Han), Limit).
|
||||||
|
|
|
@ -93,3 +93,13 @@ score_hand_dai_san_gan_test() ->
|
||||||
lists:duplicate(2, #tile{suit=wind, value=north})])
|
lists:duplicate(2, #tile{suit=wind, value=north})])
|
||||||
},
|
},
|
||||||
?assertEqual(riichi:score_hand(Hand, 30), 8000).
|
?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).
|
||||||
|
|
Loading…
Reference in a new issue