Break leaderboard ties with Melee's tiebreakers
After total of all sessions, ties fall to OMW%, GW% and OGW% over all the league's matches (bye = 2-0 win, not an opponent; opponents floored at 1/3), then name. Verified identical to Melee's order and percentages on a real night. The leaderboard shows the three percentages. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
0e14228b8f
commit
a99997b96d
4 files changed
+66
-7
No files matched your search
+18
-1
@@ -1,7 +1,7 @@
|
||||
import assert from "node:assert/strict";
|
||||
import { readFileSync } from "node:fs";
|
||||
import { test } from "node:test";
|
||||
import { computeStandings } from "../src/standings.ts";
|
||||
import { computeStandings, tiebreakers } from "../src/standings.ts";
|
||||
import { csvRows, extract, extractMatches, isMatchExport, parseTable } from "../src/tables.ts";
|
||||
|
||||
const fixture = (f: string) => parseTable(readFileSync(new URL(`./fixtures/${f}`, import.meta.url), "utf8"));
|
||||
@@ -66,3 +66,20 @@ test("a session with match rows ignores its imported standings", () => {
|
||||
const rs = [{ session_id: 1, player_id: 2, points: 99, deck: null, wins: 9, draws: 0, losses: 0 }];
|
||||
assert.equal(computeStandings(ms, rs, names, 6).rows.find((r) => r.name === "Bob")!.score, 0);
|
||||
});
|
||||
|
||||
const match = (p1_id: number, p2_id: number | null, p1_wins: number, p2_wins: number, draws = 0) =>
|
||||
({ session_id: 1, p1_id, p2_id, p1_deck: null, p2_deck: null, p1_wins, p2_wins, draws });
|
||||
|
||||
test("Melee tiebreakers: a bye is a 2-0 win but not an opponent, opponents floored at 1/3", () => {
|
||||
const tb = tiebreakers([match(1, null, 2, 0), match(1, 2, 2, 1)]);
|
||||
assert.deepEqual(tb.get(1), { omw: 1 / 3, gw: 12 / 15, ogw: 1 / 3 }); // Fay went 0-1 and 1-2, both floored
|
||||
assert.deepEqual(tb.get(2), { omw: 1, gw: 1 / 3, ogw: 12 / 15 });
|
||||
});
|
||||
|
||||
test("leaderboard: points ties fall to OMW%, then GW%, before name", () => {
|
||||
const names = new Map([[1, "Ann"], [2, "Bob"], [3, "Cy"], [4, "Dee"]]);
|
||||
const ms = [match(1, 2, 2, 0), match(3, 4, 2, 0), match(1, 3, 2, 1), match(2, 4, 2, 0)];
|
||||
const { rows } = computeStandings(ms, [], names, 6);
|
||||
// Bob and Cy: 3 points, equal OMW (Ann 100%, Dee floored to 33%); Cy's GW% 60% beats Bob's 50%
|
||||
assert.deepEqual(rows.map((r) => r.name), ["Ann", "Cy", "Bob", "Dee"]);
|
||||
});
|
||||
Reference in new issue
Block a user