From 950f34b0bd69e6e7083dbf19fb165b4b8783c068 Mon Sep 17 00:00:00 2001 From: Correl Roush Date: Tue, 8 May 2012 01:27:48 -0400 Subject: [PATCH] Scoring Suu An Kou --- src/riichi.erl | 7 +++++++ test/riichi_tests.erl | 12 ++++++++++++ 2 files changed, 19 insertions(+) diff --git a/src/riichi.erl b/src/riichi.erl index 68822bd..4dc8b71 100644 --- a/src/riichi.erl +++ b/src/riichi.erl @@ -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), diff --git a/test/riichi_tests.erl b/test/riichi_tests.erl index 254d2d4..03c11d0 100644 --- a/test/riichi_tests.erl +++ b/test/riichi_tests.erl @@ -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).