charlieviettq/awesome-agent-skill / .claude/skills/algo-rank-trueskill
"algo-rank-trueskill"
Verified"Implement TrueSkill rating system for multiplayer and team-based competitive ranking. Use this skill when the user needs to rate players in team games, handle multiplayer (non-1v1) matchups, or build a matchmaking system with uncertainty tracking — even if they say 'team rating system', 'multiplayer ranking', or 'matchmaking rating'.".
| File | Kind | Size |
|---|---|---|
| SKILL.md | skill md | 4.1 KB |
| examples/sample_scenario.md | markdown | 5.5 KB |
| references/factor-graph.md | markdown | 11.2 KB |
| references/matchmaking.md | markdown | 8.6 KB |
examples/sample_scenario.md
View on GitHub# Example: 線上射擊遊戲《SteelFront》的隊伍匹配評分系統
## Scenario
**背景:** SteelFront 是一款 5v5 戰術射擊遊戲,月活躍玩家 80,000 人。遊戲團隊反映目前用 Elo 做排名,但 Elo 無法處理隊伍對戰——每場比賽只能把一個隊伍視為「單一玩家」,忽略了個人技術差異。新玩家前 10 場比賽排名極不穩定,匹配品質投訴多。
**工程師問題:**
> 「我們有一批比賽結果(格式:兩隊各 5 名玩家、勝負),想從 Elo 遷移到 TrueSkill。能示範如何初始化、處理一批賽果、並輸出可以直接進資料庫的評分嗎?」
**給定資料(前 3 場比賽,玩家代號匿名):**
| Match | 隊伍 A | 隊伍 B | 結果 |
|-------|--------|--------|------|
| M001 | P1,P2,P3,P4,P5(全新玩家) | P6,P7,P8,P9,P10(全新玩家) | A 勝 |
| M002 | P1,P2,P3,P11,P12 | P6,P7,P8,P13,P14 | B 勝 |
| M003 | P1,P4,P5,P11,P13 | P2,P3,P6,P9,P14 | A 勝 |
---
## Analysis
### Phase 1:初始化參數
所有玩家以預設值初始:
```
μ₀ = 25.0
σ₀ = 25/3 ≈ 8.333
β = σ₀/2 ≈ 4.167 # 個人表現波動
τ = σ₀/100 ≈ 0.083 # 每場比賽的技術漂移(防止 σ 永遠收縮至 0)
```
保守排名公式:`conservative = μ - 3σ`(新玩家 = 25 - 3×8.333 = **0.0**)
**Gate 通過:** 12 位玩家均以 (25, 8.333) 初始,賽果格式正確。
---
### Phase 2:逐場更新
#### M001:P1-P5(A 隊)勝 P6-P10(B 隊)
**賽前隊伍技術分布:**
```
Team A: sum(μ) = 125.0, combined σ² = 5×8.333² + 2×4.167² ≈ 382.0 → σ_team ≈ 19.54
Team B: 同上(對稱)
```
**勝率預期:** 兩隊實力相當,A 勝概率 ≈ 50%。
**更新後(Bayesian update,A 勝出乎 50% 預期的程度不大,但仍觸發更新):**
| 玩家 | 賽前 μ | 賽前 σ | 賽後 μ | 賽後 σ |
|------|--------|--------|--------|--------|
| P1(A勝) | 25.00 | 8.333 | **27.39** | **7.862** |
| P2(A勝) | 25.00 | 8.333 | 27.39 | 7.862 |
| P6(B負) | 25.00 | 8.333 | **22.61** | **7.862** |
| P7(B負) | 25.00 | 8.333 | 22.61 | 7.862 |
> σ 從 8.333 → 7.862(下降 ~0.47):觀察到一場比賽後,不確定性降低。
---
#### M002:P1,P2,P3,P11,P12(A隊)負 P6,P7,P8,P13,P14(B隊)
此時 P1、P2 已有賽歷(μ≈27.4, σ≈7.86),P11、P12 仍是新玩家(25, 8.33)。
**A 隊加權預期略高**(P1、P2 帶起整隊),但實際輸了——更新幅度更大。
| 玩家 | 賽前 μ | 賽後 μ | Δμ | 賽後 σ |
|------|--------|--------|-----|--------|
| P1(A負) | 27.39 | **24.51** | −2.88 | 7.441 |
| P11(A負,新)| 25.00 | **22.17** | −2.83 | 7.853 |
| P6(B勝) | 22.61 | **25.84** | +3.23 | 7.411 |
| P13(B勝,新)| 25.00 | **27.98** | +2.98 | 7.848 |
> **注意 σ 不對稱性:** P1(已有 2 場)σ 降至 7.44;P11(初次登場)σ 只降至 7.85——不確定性高的新玩家 μ 變動同樣大,但 σ 仍較高。
---
#### M003:P1,P4,P5,P11,P13(A隊)勝 P2,P3,P6,P9,P14(B隊)
本場有趣:P11、P13 上一場輸球後 μ 偏低,組成 A 隊後**預期略弱**卻贏了——更新幅度放大。
| 玩家 | 賽前 μ | 賽後 μ | Δμ | 賽後 σ |
|------|--------|--------|-----|--------|
| P11(A勝) | 22.17 | **25.31** | +3.14 | 7.425 |
| P13(A勝) | 27.98 | **30.52** | +2.54 | 7.421 |
| P2(B負) | 27.39 | **24.30** | −3.09 | 7.419 |
| P6(B負) | 25.84 | **22.93** | −2.91 | 7.003 |
> P6 已出賽 3 場,σ 降至 7.00——評分漸趨收斂,信心增加。
---
### Phase 3:驗證
**σ 收斂檢查:**
```
P1:8.333 → 7.862 → 7.441 → ... ✓ 每場下降
P6:8.333 → 7.862 → 7.411 → 7.003 ✓ 三場後明顯收斂
新玩家(P14,1 場):8.333 → 7.848 ✓ 仍高,合理
```
**Gate 通過:** σ 單調遞減(加 τ 後每場微幅增加,可防過度收斂)。
---
### Phase 4:3 場後現況快照
```json
{
"ratings": [
{"player": "P6", "mu": 22.93, "sigma": 7.003, "conservative": 1.92, "games_played": 3},
{"player": "P1", "mu": 24.51, "sigma": 7.441, "conservative": 2.19, "games_played": 3},
{"player": "P11", "mu": 25.31, "sigma": 7.425, "conservative": 2.54, "games_played": 2},
{"player": "P13", "mu": 30.52, "sigma": 7.421, "conservative": 8.26, "games_played": 2},
{"player": "P2", "mu": 24.30, "sigma": 7.419, "conservative": 2.05, "games_played": 2},
{"player": "P14", "mu": 27.98, "sigma": 7.848, "conservative": 4.44, "games_played": 1}
],
"metadata": {
"initial_mu": 25,
"initial_sigma": 8.333,
"beta": 4.167,
"tau": 0.083,
"note": "conservative = mu - 3*sigma; rankings should use conservative until sigma < 3.0"
}
}
```
---
## Result
**給 SteelFront 工程師的結論:**
1. **遷移建議:** 以 (μ=25, σ=8.333) 初始化所有既有玩家,用過去 Elo 排名做 μ 預熱(`μ_init = 25 + (elo - 1200) / 80`)可縮短 σ 收斂期。
2. **排行榜顯示:** 前 10 場使用保守排名(μ − 3σ),10 場後改為 μ − 2σ,50 場後直接使用 μ——避免新玩家「評分充氣」。
3. **關鍵陷阱(本案例適用):**
- P13 只出賽 2 場就有 μ=30.52,但 σ=7.42 仍高,conservative=8.26——**不應讓他進高段位匹配隊列**,需等 σ < 4。
- 不要把 Elo 的「積分差」直接映射為 TrueSkill 的 μ 差:Elo 沒有不確定性維度,兩者無線性對應。
4. **匹配品質指標:** 對局開始前計算兩隊 draw probability,目標 > 30% 才開賽,可大幅降低一面倒比賽。
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| reverse-engineer-anythingmorluto/reaReverse engineer native, managed, Electron/JavaScript, packaged, firmware, and browser targets with REA, and build agent environments (AgentEnv bundles) of web applications from a live instance or a capture, and of Linux desktop apps with a task from a request. Use shipped-artifact or requested runtime evidence to explain features, compare versions, decompile code, or guide a reconstruction. Skip REA for ordinary source-repository architecture analysis. | Stars: 472k | Updated | Claude CodeCodex | Verified | Install |
| diagnosing-superpowersobra/superpowersUse when a superpowers session went wrong and your human partner wants to know why — repeated work, ignored plans, stumbles, poor results, a skill that didn't fire, "it took too long", "why is it so expensive", "what is it doing" — or wants to build a bug report for the superpowers maintainers, for the current session or a past one identified by id or path, on any harness. | Stars: 323k | Updated | Claude CodeCodex | Verified | Install |
| dispatching-parallel-agentsobra/superpowersUse when facing 2+ independent tasks that can be worked on without shared state or sequential dependencies | Stars: 323k | Updated | Claude CodeCodex | Verified | Install |
| executing-plansobra/superpowersUse when executing an implementation plan in the current session as the implementer yourself — your human partner chose inline execution, or no subagent tool is available | Stars: 323k | Updated | Claude CodeCodex | Verified | Install |