pull/1/head
parent
5d660ff39a
commit
6e0c8a80f3
|
|
@ -1 +1,4 @@
|
||||||
pytest tests/
|
loguru~=0.7.2
|
||||||
|
pytest~=8.3.3
|
||||||
|
gym~=0.26.2
|
||||||
|
numpy~=2.1.3
|
||||||
|
|
@ -11,7 +11,7 @@ def calculate_score(fan: int, base_score: int, is_self_draw: bool, is_dealer: bo
|
||||||
返回:
|
返回:
|
||||||
- scores: 字典,包含赢家得分和输家扣分。
|
- scores: 字典,包含赢家得分和输家扣分。
|
||||||
"""
|
"""
|
||||||
# 翻倍计算总分
|
# 翻倍计算基础分
|
||||||
total_score = base_score * (2 ** fan)
|
total_score = base_score * (2 ** fan)
|
||||||
|
|
||||||
if is_self_draw:
|
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:
|
if is_dealer:
|
||||||
# 庄家自摸:每家付单倍总分
|
# 庄家自摸:每家付单倍总分
|
||||||
per_loser_score = -total_score
|
per_loser_score = -total_score
|
||||||
winner_score = -3 * per_loser_score
|
winner_score = total_score * 3 # 三家支付的总和
|
||||||
return {
|
return {
|
||||||
"winner": winner_score,
|
"winner": winner_score,
|
||||||
"loser": [per_loser_score] * 3
|
"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
|
dealer_loss = -total_score * 2
|
||||||
other_loss = -total_score
|
other_loss = -total_score
|
||||||
winner_score = -dealer_loss + 2 * other_loss
|
winner_score = -dealer_loss + 2 * -other_loss # 庄家和两闲家支付总和
|
||||||
return {
|
return {
|
||||||
"winner": winner_score,
|
"winner": winner_score,
|
||||||
"loser": [dealer_loss, other_loss, other_loss]
|
"loser": [dealer_loss, other_loss, other_loss]
|
||||||
}
|
}
|
||||||
else:
|
else:
|
||||||
# 点炮,点炮者独付
|
# 点炮,点炮者独付
|
||||||
|
loser_score = -total_score
|
||||||
|
winner_score = total_score
|
||||||
if is_dealer:
|
if is_dealer:
|
||||||
# 庄家点炮
|
# 庄家点炮
|
||||||
loser_score = -total_score
|
|
||||||
winner_score = -loser_score
|
|
||||||
return {
|
return {
|
||||||
"winner": winner_score,
|
"winner": winner_score,
|
||||||
"loser": [loser_score, 0, 0]
|
"loser": [loser_score, 0, 0]
|
||||||
}
|
}
|
||||||
else:
|
else:
|
||||||
# 闲家点炮
|
# 闲家点炮
|
||||||
loser_score = -total_score
|
|
||||||
winner_score = -loser_score
|
|
||||||
return {
|
return {
|
||||||
"winner": winner_score,
|
"winner": winner_score,
|
||||||
"loser": [loser_score, 0, 0]
|
"loser": [loser_score, 0, 0]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -31,8 +31,8 @@ def test_non_dealer_point_win():
|
||||||
|
|
||||||
def test_non_dealer_self_draw():
|
def test_non_dealer_self_draw():
|
||||||
"""
|
"""
|
||||||
测试用例 3: 闲家自摸,总番数 4,底分 10
|
测试用例 3: 闲家自摸,总番数 4,底分 10
|
||||||
"""
|
"""
|
||||||
fan = 4
|
fan = 4
|
||||||
base_score = 10
|
base_score = 10
|
||||||
is_self_draw = True
|
is_self_draw = True
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue