From 6e0c8a80f38198de67c060b18554b0116ab4d939 Mon Sep 17 00:00:00 2001 From: wsy182 <2392948297@qq.com> Date: Sat, 30 Nov 2024 17:17:28 +0800 Subject: [PATCH] 1 --- requirements.txt | 5 ++++- src/engine/scoring.py | 13 ++++++------- tests/test_scoring.py | 4 ++-- 3 files changed, 12 insertions(+), 10 deletions(-) diff --git a/requirements.txt b/requirements.txt index defad62..cc2588e 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1 +1,4 @@ -pytest tests/ \ No newline at end of file +loguru~=0.7.2 +pytest~=8.3.3 +gym~=0.26.2 +numpy~=2.1.3 \ No newline at end of file diff --git a/src/engine/scoring.py b/src/engine/scoring.py index 0843adf..24ce2c8 100644 --- a/src/engine/scoring.py +++ b/src/engine/scoring.py @@ -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] } + diff --git a/tests/test_scoring.py b/tests/test_scoring.py index 8094042..9014010 100644 --- a/tests/test_scoring.py +++ b/tests/test_scoring.py @@ -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