diff --git a/app/components/header.tsx b/app/components/header.tsx index 68ffd37..c67f788 100644 --- a/app/components/header.tsx +++ b/app/components/header.tsx @@ -205,7 +205,7 @@ export default function Header({

- Jep! + Nep!

diff --git a/app/engine/engine.test.ts b/app/engine/engine.test.ts index 1bddd8e..705fc38 100644 --- a/app/engine/engine.test.ts +++ b/app/engine/engine.test.ts @@ -2208,11 +2208,12 @@ describe("gameEngine", () => { }); describe("getWinningBuzzer", () => { - it("returns the buzz of the lower user ID in case of a tie", () => { + it("measures the buzzer winrate between two equally fast players over 1000 trials. Expected to be near 50-50", () => { let player1Wins = 0; - for (let charCode = 16; charCode <= 116; charCode++) { - let tiebreakSeed = String.fromCharCode(charCode); - let buzzes = new Map(); + const n_trials = 1000; + for (let trial = 0; trial < n_trials; trial++) { + const tiebreakSeed = Math.random().toString() + trial.toString(); + const buzzes = new Map(); buzzes.set(PLAYER1.userId, 100); buzzes.set(PLAYER2.userId, 100); const winner = getWinningBuzzer(buzzes, tiebreakSeed)?.userId; @@ -2220,7 +2221,9 @@ describe("getWinningBuzzer", () => { player1Wins++; } } - expect(player1Wins).toBeGreaterThan(30); - expect(player1Wins).toBeLessThan(70); + // CDF of bin(n=1000, p=0.5) = 0.99999 @ k = 435 + const k = 435; + expect(player1Wins).toBeGreaterThan(k); + expect(player1Wins).toBeLessThan(n_trials - k); }); }); diff --git a/app/engine/engine.ts b/app/engine/engine.ts index fb2b293..e1ad568 100644 --- a/app/engine/engine.ts +++ b/app/engine/engine.ts @@ -97,7 +97,7 @@ export function getWinningBuzzer( }); const sortedBuzzes = quantizedBuzzes.sort( - ([_a, qDeltaA, tiebreakA], [_b, qDeltaB, tiebreakB]) => { + ([, qDeltaA, tiebreakA], [, qDeltaB, tiebreakB]) => { if (qDeltaA === qDeltaB) { return tiebreakA - tiebreakB; } else { @@ -432,14 +432,7 @@ export function gameEngine(state: State, action: Action): State { return; } } else { -<<<<<<< HEAD - const winningBuzzer = getWinningBuzzer( - draft.buzzes, - draft.clue?.clue, - ); -======= const winningBuzzer = getWinningBuzzer(draft.buzzes, clueText); ->>>>>>> 7af7760 (use tiebreak at all getWinningBuzzer callsites) if (userId !== winningBuzzer?.userId) { return; }