From fe0636f84e223097f35268a6a16b6c0ea5bbdf03 Mon Sep 17 00:00:00 2001 From: wsy182 <2392948297@qq.com> Date: Sat, 30 Nov 2024 15:05:11 +0800 Subject: [PATCH] 1 1 --- src/engine/calculate_fan.py | 7 +++++-- tests/test_calculate_fan.py | 3 +++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/engine/calculate_fan.py b/src/engine/calculate_fan.py index 33ca5c1..42c03cf 100644 --- a/src/engine/calculate_fan.py +++ b/src/engine/calculate_fan.py @@ -16,7 +16,7 @@ def calculate_fan(hand, melds, is_self_draw, is_cleared, conditions): # 定义番种规则 rules = { - "basic_win": lambda: 1 if not conditions.get("is_seven_pairs", False) else 0, # 平胡(七对不加基本胡) + "basic_win": lambda: 1 if not (conditions.get("is_seven_pairs", False) or conditions.get("is_big_pairs", False)) else 0, # 平胡(七对或大对子不加基本胡) "is_cleared": lambda: 2 if is_cleared else 0, # 清一色 "is_pure_cleared": lambda: 3 if is_cleared and len(melds) >= 1 else 0, # 清对 "is_double_pure_cleared": lambda: 4 if is_cleared and len(melds) >= 2 else 0, # 极中极 @@ -65,4 +65,7 @@ def is_big_pairs(hand): """ from collections import Counter counter = Counter(hand) - return all(count == 3 or count == 2 for count in counter.values()) + result = all(count == 3 or count == 2 for count in counter.values()) + print(f"Big pairs check: {result}, Counter: {counter}") + return result + diff --git a/tests/test_calculate_fan.py b/tests/test_calculate_fan.py index 3ecaa70..34d8ca1 100644 --- a/tests/test_calculate_fan.py +++ b/tests/test_calculate_fan.py @@ -91,6 +91,9 @@ def test_big_pairs(): melds = [] conditions = {"is_big_pairs": is_big_pairs(hand)} + # 确保大对子检测正确 + assert is_big_pairs(hand), "The hand is not identified as a big pairs hand." + fan = calculate_fan(hand, melds, is_self_draw=False, is_cleared=False, conditions=conditions) assert fan == 2, f"Expected 2 fans (big pairs), got {fan}"