pull/1/head
wsy182 2024-11-30 17:17:28 +08:00
parent 5d660ff39a
commit 6e0c8a80f3
3 changed files with 12 additions and 10 deletions

View File

@ -1 +1,4 @@
pytest tests/
loguru~=0.7.2
pytest~=8.3.3
gym~=0.26.2
numpy~=2.1.3

View File

@ -11,7 +11,7 @@ def calculate_score(fan: int, base_score: int, is_self_draw: bool, is_dealer: bo
返回:
- scores: 字典包含赢家得分和输家扣分
"""
# 翻倍计算
# 翻倍计算基础
total_score = base_score * (2 ** fan)
if is_self_draw:
@ -19,7 +19,7 @@ def calculate_score(fan: int, base_score: int, is_self_draw: bool, is_dealer: bo
if is_dealer:
# 庄家自摸:每家付单倍总分
per_loser_score = -total_score
winner_score = -3 * per_loser_score
winner_score = total_score * 3 # 三家支付的总和
return {
"winner": winner_score,
"loser": [per_loser_score] * 3
@ -28,26 +28,25 @@ def calculate_score(fan: int, base_score: int, is_self_draw: bool, is_dealer: bo
# 闲家自摸:庄家付双倍,其他两家付单倍
dealer_loss = -total_score * 2
other_loss = -total_score
winner_score = -dealer_loss + 2 * other_loss
winner_score = -dealer_loss + 2 * -other_loss # 庄家和两闲家支付总和
return {
"winner": winner_score,
"loser": [dealer_loss, other_loss, other_loss]
}
else:
# 点炮,点炮者独付
loser_score = -total_score
winner_score = total_score
if is_dealer:
# 庄家点炮
loser_score = -total_score
winner_score = -loser_score
return {
"winner": winner_score,
"loser": [loser_score, 0, 0]
}
else:
# 闲家点炮
loser_score = -total_score
winner_score = -loser_score
return {
"winner": winner_score,
"loser": [loser_score, 0, 0]
}

View File

@ -31,8 +31,8 @@ def test_non_dealer_point_win():
def test_non_dealer_self_draw():
"""
测试用例 3: 闲家自摸总番数 4底分 10
"""
测试用例 3: 闲家自摸总番数 4底分 10
"""
fan = 4
base_score = 10
is_self_draw = True