mjAi/src/engine/scoring.py

33 lines
940 B
Python

def calculate_score(fan: int, base_score: int, is_self_draw: bool) -> dict:
"""
根据成都麻将规则计算得分(不区分庄家和闲家)。
参数:
- fan: 总番数。
- base_score: 底分。
- is_self_draw: 是否为自摸。
返回:
- scores: 字典,包含赢家得分和输家扣分。
"""
# 计算总分
multiplier = 2 ** fan # 根据番数计算倍率
total_score = base_score * multiplier
if is_self_draw:
# 自摸:三家平摊分数
per_loser_score = -total_score
winner_score = total_score * 3 # 总赢家得分
return {
"winner": winner_score,
"loser": [per_loser_score] * 3
}
else:
# 点炮:点炮者独付
loser_score = -total_score
winner_score = total_score
return {
"winner": winner_score,
"loser": [loser_score, 0, 0]
}