예제 소스
SGF 기보로 학습하는 바둑 LLM 인공지능 · 파일 169개
ranking.test.mjs
import assert from "node:assert/strict";
import test from "node:test";
import { applyRankOutcome, promotionTarget, rankLabel } from "./ranking.ts";
test("급수 구간별 승급 승점", () => {
assert.equal(promotionTarget(0), 3); // 18급
assert.equal(promotionTarget(7), 3); // 11급
assert.equal(promotionTarget(8), 5); // 10급
assert.equal(promotionTarget(13), 5); // 5급
assert.equal(promotionTarget(14), 10); // 4급
assert.equal(promotionTarget(17), 10); // 1급
assert.equal(promotionTarget(18), 15); // 1단
});
test("승급 시 승점을 초기화하고 다음 급수로 이동", () => {
assert.deepEqual(applyRankOutcome(0, 2, "win"), {
rankLevel: 1,
rankPoints: 0,
promoted: true,
demoted: false,
});
assert.equal(rankLabel(1), "17급");
assert.deepEqual(applyRankOutcome(17, 9, "win"), {
rankLevel: 18,
rankPoints: 0,
promoted: true,
demoted: false,
});
assert.equal(rankLabel(18), "1단");
});
test("패배는 -1점, 무승부는 승점 유지", () => {
assert.deepEqual(applyRankOutcome(8, 0, "loss"), {
rankLevel: 8,
rankPoints: -1,
promoted: false,
demoted: false,
});
assert.deepEqual(applyRankOutcome(18, 7, "draw"), {
rankLevel: 18,
rankPoints: 7,
promoted: false,
demoted: false,
});
});
test("구간별 음수 기준에 도달하면 한 급 내려가고 승점을 초기화", () => {
assert.deepEqual(applyRankOutcome(1, -2, "loss"), {
rankLevel: 0,
rankPoints: 0,
promoted: false,
demoted: true,
});
assert.deepEqual(applyRankOutcome(8, -4, "loss"), {
rankLevel: 7,
rankPoints: 0,
promoted: false,
demoted: true,
});
assert.deepEqual(applyRankOutcome(14, -9, "loss"), {
rankLevel: 13,
rankPoints: 0,
promoted: false,
demoted: true,
});
assert.deepEqual(applyRankOutcome(18, -14, "loss"), {
rankLevel: 17,
rankPoints: 0,
promoted: false,
demoted: true,
});
});
test("18급에서는 더 강등하지 않고 승점만 초기화", () => {
assert.deepEqual(applyRankOutcome(0, -2, "loss"), {
rankLevel: 0,
rankPoints: 0,
promoted: false,
demoted: false,
});
});