MahjongRepository / mahjong

Implementation of riichi mahjong related stuff (hand cost, shanten, agari end, etc.)
MIT License
377 stars 38 forks source link

Missing duplicate pair check for Chiitoitsu #38

Closed Mystouille closed 3 years ago

Mystouille commented 3 years ago

Code for Chiitoitsu is: def is_condition_met(self, hand, *args): return len(hand) == 7

But riichi rules specify that all pairs must be different. I suggest something like:

def is_condition_met(self, hand, *args): return len(hand) == 7 and len(set(hand))==len(hand)

Nihisil commented 3 years ago

Thanks for the report!

Nihisil commented 3 years ago

Actually there we don't have a bug, the validation on identical pairs will be done before we are checking hand on chitoitsu yaku. I added the unit test to confirm it: https://github.com/MahjongRepository/mahjong/commit/98efa913d5fc71641629614663efafc06d86b608

Let me know if you still think that there is a bug.