Scoring Ryuu-Ii-Sou

This commit is contained in:
Correl Roush 2012-05-08 10:46:00 -04:00
parent a50d5d3087
commit 3bd4ddee64
2 changed files with 22 additions and 0 deletions

View file

@ -103,6 +103,17 @@ score_hand(#hand{}=Hand, BaseFu, Limit) ->
_ -> 0 _ -> 0
end end
end, end,
_Ryuu_Ii_Sou = fun(#hand{}=H) ->
Set = sets:from_list(H#hand.tiles),
Greens = sets:from_list(lists:flatten([
[#tile{suit=sou, value=V} || V <- [2,3,4,6,8]],
[#tile{suit=dragon, value=green}]
])),
case sets:is_subset(Set, Greens) of
true -> 13;
_ -> 0
end
end,
_Kokushi_Musou = fun(#hand{}=H) -> _Kokushi_Musou = fun(#hand{}=H) ->
Sets = find_sets(H#hand.tiles), 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), Terminals = not lists:any(fun(#tile{value=V}) -> lists:member(V, lists:seq(2,8)) end, H#hand.tiles),

View file

@ -115,3 +115,14 @@ score_hand_kokushi_musou_test() ->
[#tile{suit=pin, value=1}]]) [#tile{suit=pin, value=1}]])
}, },
?assertEqual(riichi:score_hand(Hand, 30), 8000). ?assertEqual(riichi:score_hand(Hand, 30), 8000).
score_hand_ryuu_ii_sou_test() ->
Hand = #hand{
tiles = lists:flatten([
[#tile{suit=sou, value=V} || V <- [2,3,4]],
[#tile{suit=sou, value=V} || V <- [2,3,4]],
lists:duplicate(3, #tile{suit=sou, value=6}),
lists:duplicate(3, #tile{suit=sou, value=8}),
lists:duplicate(2, #tile{suit=dragon, value=green})])
},
?assertEqual(riichi:score_hand(Hand, 30), 8000).