feat: ルール細則に基づく順位計算モジュールの実装 - #25
Open
arumino-om wants to merge 3 commits into
Open
Conversation
対戦結果の配列から試合の勝敗を判定し、順位表を返す。 先攻・後攻を入れ替えた2対戦を1試合として扱い、勝因の重み (自滅 > Put勝ち > アイテム数優勢) 順の辞書式比較で勝敗を決める。 引き分けは再試合が必要な試合として印を付け、同じ組み合わせの 後続試合が再試合として行われていれば元の結果を無効にする。 POST /ranking で順位表を取得できる。 Refs #19 Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
順位計算の仕様と、ルール細則に無いため補った点を記載した。 あわせて .gitignore の __pycache__ のタイポを修正した。 Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
amemya
requested changes
Aug 12, 2026
| [build-system] | ||
| requires = ["poetry-core>=2.0.0,<3.0.0"] | ||
| build-backend = "poetry.core.masonry.api" | ||
|
|
There was a problem hiding this comment.
Suggested change
| [tool.poetry.group.dev.dependencies] | |
| pytest = ">=8.0,<9.0" | |
| httpx = ">=0.28.0,<0.29.0" | |
テスト関連はdevグループの依存関係に追加するのがスムーズになるかなと思います
Comment on lines
+146
to
+151
| pytest と httpx はランタイム依存に含めていないため、個別に入れる。 | ||
|
|
||
| ```bash | ||
| pip install pytest httpx | ||
| pytest | ||
| ``` |
There was a problem hiding this comment.
Suggested change
| pytest と httpx はランタイム依存に含めていないため、個別に入れる。 | |
| ```bash | |
| pip install pytest httpx | |
| pytest | |
| ``` | |
| ```bash | |
| poetry run pytest | |
| ``` |
Poetryを利用しているのであればPoetryが管理するvenvに対して直接pip installするのは本来避けるべきパターンです
前述した変更を取り入れる場合はこちらも要修正
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
概要
chros-score に、ルール細則に従って順位を計算するモジュールを追加しました。
対戦結果の配列を受け取り、試合の勝敗判定と順位表を返します。
src/score_api/ranking/models.py— 入出力モデルと勝因の定義src/score_api/ranking/calculator.py— 試合判定と順位表の組み立てPOST /ranking— APIエンドポイント入力
[ { "hot": "player1", "cool": "player2", "winner": "hot", "reason": "put" }, { "hot": "player2", "cool": "player1", "winner": "cool", "reason": "item" } ]hot/coolwinnerhot/cool/drawreasonself_destruct/put/item。drawのときは省略reasonはLostConnect、timeout、アイテム数優勢などの表記ゆれも受け付けます。判定ロジック
rematch_requiredを立てます。同じ組み合わせの試合が後続にあればそれを再試合とみなし、前の引き分け試合をvoidedにして集計から除外します(1-4)。出力
standings(順位表)とmatches(試合ごとの判定結果)を返します。判定の補足は自然言語ではなくコードで返すため、呼び出し側でそのまま分岐できます。coderulescore_tiedrematch_heldbouts_missingsides_not_swapped細則に無いため補った点(要確認)
pending_rematchesとして別途カウントします。テスト
chros-scoreでpytest(13件パス)。pytest / httpx はランタイム依存に含めていないため、poetry.lockは変更していません。Refs #19
🤖 Generated with Claude Code