범인찾기 C4: 기록 점수 (OP.GG OP스코어 방식) + LOL.PS 라인전
- packages/shared/src/rating.ts: 발로란트(라운드 승률 · KAST · ACS · 피해 격차) · 롤(킬 관여 · 데스 · 딜/받은 피해/골드 비중 · CS · 레벨 · CC · 와드) 0~10 점수, 경기/팀 순위, MVP · ACE, 점수를 올리고 깎은 지표, 롤 15분 맞라인 비교 - 계수: OP.GG 공식 MCP 로 받은 실제 경기의 OP스코어에 맞춤 (tools/opscore-fit). 교차 검증 발로란트 상관 0.968 · 오차 0.49, 롤 상관 0.943 · 오차 0.60 · 팀 최하위 일치 85% - 발로란트 경기 상세에 KAST 라운드 수(5초 트레이드) · 받은 피해 저장 - AI 자료에 '# 기록 점수' 칸, 참가자 줄에 KAST · 피해 격차, OP.GG 에서 경기를 찾을 정보(lookup), 참가자에 태그 · 기록 점수 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
57
app/test/rating.test.ts
Normal file
57
app/test/rating.test.ts
Normal file
@@ -0,0 +1,57 @@
|
||||
import { test } from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import fs from 'node:fs';
|
||||
import { rateLol, rateValorant, type MatchPlayer, type MatchRound } from '@gvr/shared';
|
||||
|
||||
/** OP.GG 공식 MCP 에서 받은 실제 경기 (tools/opscore-fit/make_fixture.py). 우리 계산이 실제 OP.GG 점수와 가까운지 본다 */
|
||||
const sample = JSON.parse(fs.readFileSync(new URL('./fixtures/opgg-sample.json', import.meta.url), 'utf8'));
|
||||
|
||||
test('기록 점수 (롤): 실제 OP.GG OP스코어와 평균 오차 · 팀 최하위 일치', () => {
|
||||
let err = 0;
|
||||
let n = 0;
|
||||
let teams = 0;
|
||||
let lowestHit = 0;
|
||||
for (const g of sample.lol) {
|
||||
const players = g.players as (MatchPlayer & { opgg: number })[];
|
||||
const r = rateLol(players, g.minutes, g.allyWin);
|
||||
for (const p of players) {
|
||||
err += Math.abs(r.get(p.puuid)!.score - p.opgg);
|
||||
n++;
|
||||
}
|
||||
for (const team of ['BLUE', 'RED']) {
|
||||
const ps = players.filter((p) => p.team === team);
|
||||
teams++;
|
||||
const ours = ps.reduce((a, b) => (r.get(a.puuid)!.score <= r.get(b.puuid)!.score ? a : b));
|
||||
const theirs = ps.reduce((a, b) => (a.opgg <= b.opgg ? a : b));
|
||||
if (ours === theirs) lowestHit++;
|
||||
}
|
||||
// 이긴 팀 1등 MVP, 진 팀 1등 ACE
|
||||
const badges = [...r.values()].map((x) => x.badge).filter(Boolean).sort();
|
||||
assert.deepEqual(badges, ['ACE', 'MVP']);
|
||||
}
|
||||
const mae = err / n;
|
||||
assert.ok(mae < 0.75, `평균 오차 ${mae.toFixed(2)}`);
|
||||
assert.ok(lowestHit / teams >= 0.75, `팀 최하위 일치 ${lowestHit}/${teams}`);
|
||||
});
|
||||
|
||||
test('기록 점수 (발로란트): 실제 OP.GG OP스코어와 평균 오차', () => {
|
||||
let err = 0;
|
||||
for (const v of sample.valorant) {
|
||||
const rounds = Array.from({ length: v.rounds }, (_, i) => ({ win: i < v.wonRounds }) as MatchRound);
|
||||
const r = rateValorant([v.player], rounds).get('v')!;
|
||||
assert.equal(r.basic, false);
|
||||
err += Math.abs(r.score - v.opgg);
|
||||
}
|
||||
const mae = err / sample.valorant.length;
|
||||
assert.ok(mae < 0.7, `평균 오차 ${mae.toFixed(2)}`);
|
||||
});
|
||||
|
||||
test('기록 점수: 추가 지표가 없는 예전 경기는 기본 기록 모델, 설명은 상식 방향만', () => {
|
||||
const g = sample.lol[0];
|
||||
const bare = g.players.map(({ stats: _s, ...p }: any) => p);
|
||||
const r = rateLol(bare, g.minutes, g.allyWin);
|
||||
assert.ok([...r.values()].every((x) => x.basic && x.score >= 0 && x.score <= 10));
|
||||
// 데스가 가장 많은 사람에게 "데스" 가 강점으로 붙지 않는다
|
||||
const full = rateLol(g.players, g.minutes, g.allyWin);
|
||||
for (const x of full.values()) for (const part of x.parts) if (/데스/.test(part.text)) assert.equal(part.good, false, part.text);
|
||||
});
|
||||
Reference in New Issue
Block a user