Wait detection

This commit is contained in:
Correl Roush 2012-07-31 22:23:46 -04:00
parent ec8ed129a5
commit a74bff6d8f

View file

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