Wait detection

This commit is contained in:
Correl Roush 2012-07-31 22:23:46 -04:00
parent e8b9f10b18
commit 0382253c98

View file

@ -4,6 +4,9 @@
-compile([export_all]).
find(#hand{} = Hand) ->
%find(lists:sort(Tiles), Hand#hand{tiles=[]}, []);
find(lists:sort(tiles(Hand)));
find(Tiles) ->
find(lists:sort(Tiles), #hand{}, []).
@ -55,9 +58,14 @@ is_complete(#hand{tiles=[], melds=Melds}=Hand) ->
length(Melds) =:= 5;
7 ->
% Must be seven *unique* pairs
yaku:chiitoitsu(Hand);
yaku:chiitoitsu(#game{}, #player{hand=Hand});
_ ->
false
end;
is_complete(#hand{}=Hand) ->
yaku:kokushi_musou(Hand).
yaku:kokushi_musou(#game{}, #player{hand=Hand}).
waits(#hand{}=Hand) ->
[T || T <- ?TILES,
0 < length([H || H <- find(tiles(Hand) ++ [T]),
is_complete(H)])].