mirror of
https://github.com/correl/riichi.git
synced 2024-11-23 19:19:55 +00:00
Prettied up yakuman scoring
This commit is contained in:
parent
55faf8b96e
commit
2fdf7c8240
1 changed files with 20 additions and 9 deletions
|
@ -81,21 +81,32 @@ score_hand(#hand{}=H) ->
|
||||||
score_hand(#hand{}=H, Fu) ->
|
score_hand(#hand{}=H, Fu) ->
|
||||||
score_hand(H, Fu, true).
|
score_hand(H, Fu, true).
|
||||||
|
|
||||||
score_hand(#hand{tiles=T, sets=_S}=_H, BaseFu, Limit) ->
|
score_hand(#hand{}=Hand, BaseFu, Limit) ->
|
||||||
Fu = [
|
Fu = [
|
||||||
BaseFu
|
BaseFu
|
||||||
],
|
],
|
||||||
Han = [
|
Yakuman = [
|
||||||
_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 = fun(#hand{}=H) ->
|
||||||
true -> 13;
|
Sets = find_sets(H#hand.tiles),
|
||||||
_ -> 0
|
HasRed = lists:member({3, #tile{suit=dragon, value=red}}, Sets),
|
||||||
end,
|
HasWhite = lists:member({3, #tile{suit=dragon, value=white}}, Sets),
|
||||||
_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
|
HasGreen = lists:member({3, #tile{suit=dragon, value=green}}, Sets),
|
||||||
|
case HasRed and HasWhite and HasGreen of
|
||||||
true -> 13;
|
true -> 13;
|
||||||
_ -> 0
|
_ -> 0
|
||||||
end
|
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),
|
||||||
|
Orphans = 13 == length([C || {C, _T} <- Sets, C == 1]),
|
||||||
|
case Terminals and Orphans of
|
||||||
|
true -> 13;
|
||||||
|
_ -> 0
|
||||||
|
end
|
||||||
|
end
|
||||||
],
|
],
|
||||||
score(lists:sum(Fu), lists:sum(Han), Limit).
|
score(lists:sum(Fu), [F(Hand) || F <- Yakuman], Limit).
|
||||||
|
|
||||||
find_sets(Tiles) ->
|
find_sets(Tiles) ->
|
||||||
Unique = sets:to_list(sets:from_list(Tiles)),
|
Unique = sets:to_list(sets:from_list(Tiles)),
|
||||||
|
|
Loading…
Reference in a new issue