通过计番测试
parent
fe0636f84e
commit
c5c37bb36d
|
|
@ -16,11 +16,11 @@ def calculate_fan(hand, melds, is_self_draw, is_cleared, conditions):
|
|||
|
||||
# 定义番种规则
|
||||
rules = {
|
||||
"basic_win": lambda: 1 if not (conditions.get("is_seven_pairs", False) or conditions.get("is_big_pairs", False)) else 0, # 平胡(七对或大对子不加基本胡)
|
||||
"basic_win": lambda: 1 if not (conditions.get("is_seven_pairs", False) or conditions.get("is_big_pairs", False) or conditions.get("is_dragon_seven_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, # 极中极
|
||||
"is_seven_pairs": lambda: 2 if conditions.get("is_seven_pairs", False) else 0, # 七对
|
||||
"is_seven_pairs": lambda: 2 if conditions.get("is_seven_pairs", False) and not conditions.get("is_dragon_seven_pairs", False) else 0,
|
||||
"is_dragon_seven_pairs": lambda: 12 if conditions.get("is_dragon_seven_pairs", False) else 0, # 龙七对
|
||||
"is_clear_seven_pairs": lambda: 12 if conditions.get("is_clear_seven_pairs", False) else 0, # 清七对
|
||||
"is_big_pairs": lambda: 2 if conditions.get("is_big_pairs", False) else 0, # 大对子
|
||||
|
|
@ -65,7 +65,10 @@ def is_big_pairs(hand):
|
|||
"""
|
||||
from collections import Counter
|
||||
counter = Counter(hand)
|
||||
result = all(count == 3 or count == 2 for count in counter.values())
|
||||
print(f"Big pairs check: {result}, Counter: {counter}")
|
||||
|
||||
counts = [count for count in hand if count > 0]
|
||||
result = counts.count(2) == 1 and counts.count(3) >= 3
|
||||
print(f"Big pairs check: {result}, Counter: {Counter(counts)}")
|
||||
return result
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -91,6 +91,9 @@ def test_big_pairs():
|
|||
melds = []
|
||||
conditions = {"is_big_pairs": is_big_pairs(hand)}
|
||||
|
||||
# Debug output
|
||||
print(f"Conditions: {conditions}")
|
||||
|
||||
# 确保大对子检测正确
|
||||
assert is_big_pairs(hand), "The hand is not identified as a big pairs hand."
|
||||
|
||||
|
|
@ -98,6 +101,7 @@ def test_big_pairs():
|
|||
assert fan == 2, f"Expected 2 fans (big pairs), got {fan}"
|
||||
|
||||
|
||||
|
||||
def test_gang_flower():
|
||||
"""
|
||||
测试杠上开花计分
|
||||
|
|
@ -137,7 +141,10 @@ def test_dragon_seven_pairs():
|
|||
hand[24] = 4 # 龙: 7条
|
||||
|
||||
melds = []
|
||||
conditions = {"is_dragon_seven_pairs": True}
|
||||
conditions = {
|
||||
"is_dragon_seven_pairs": True,
|
||||
"is_seven_pairs": True,
|
||||
}
|
||||
|
||||
fan = calculate_fan(hand, melds, is_self_draw=True, is_cleared=False, conditions=conditions)
|
||||
assert fan == 13, f"Expected 13 fans (1 self-draw + 12 dragon seven pairs), got {fan}"
|
||||
|
|
|
|||
Loading…
Reference in New Issue