parent
f745506792
commit
fe0636f84e
|
|
@ -16,7 +16,7 @@ def calculate_fan(hand, melds, is_self_draw, is_cleared, conditions):
|
||||||
|
|
||||||
# 定义番种规则
|
# 定义番种规则
|
||||||
rules = {
|
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_cleared": lambda: 2 if is_cleared else 0, # 清一色
|
||||||
"is_pure_cleared": lambda: 3 if is_cleared and len(melds) >= 1 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_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
|
from collections import Counter
|
||||||
counter = Counter(hand)
|
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
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -91,6 +91,9 @@ def test_big_pairs():
|
||||||
melds = []
|
melds = []
|
||||||
conditions = {"is_big_pairs": is_big_pairs(hand)}
|
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)
|
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}"
|
assert fan == 2, f"Expected 2 fans (big pairs), got {fan}"
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue