45 lines
1.8 KiB
TypeScript
45 lines
1.8 KiB
TypeScript
import { describe, expect, it } from "vitest";
|
|
import {
|
|
arenaAiProfile,
|
|
arenaDampening,
|
|
arenaDrDuration,
|
|
arenaRatingBand,
|
|
calculateArenaRating,
|
|
clampArenaRating,
|
|
} from "./arenaRules";
|
|
|
|
describe("arena rating and difficulty", () => {
|
|
it("clamps ratings and applies the requested Elo bands", () => {
|
|
expect(clampArenaRating(-5)).toBe(0);
|
|
expect(clampArenaRating(2600)).toBe(2500);
|
|
expect(arenaRatingBand(0)).toMatchObject({ title: "Recruit", k: 64 });
|
|
expect(arenaRatingBand(2400)).toMatchObject({ title: "Gladiator", k: 20 });
|
|
expect(calculateArenaRating(0, 0, 1)).toMatchObject({ delta: 32, after: 32 });
|
|
expect(calculateArenaRating(0, 0, 0)).toMatchObject({ delta: 0, after: 0 });
|
|
expect(calculateArenaRating(1250, 1250, 0.5)).toMatchObject({ delta: 0, after: 1250 });
|
|
});
|
|
|
|
it("continuously improves bots without removing the error floor", () => {
|
|
const recruit = arenaAiProfile(0);
|
|
const rival = arenaAiProfile(1600);
|
|
const gladiator = arenaAiProfile(2500);
|
|
expect(rival.reactionMinSeconds).toBeLessThan(recruit.reactionMinSeconds);
|
|
expect(gladiator.healerInterruptChance).toBe(0.85);
|
|
expect(gladiator.minimumErrorChance).toBe(0.08);
|
|
});
|
|
|
|
it("starts dampening at ten percent and reaches zero healing at nine minutes", () => {
|
|
expect(arenaDampening(0)).toBeCloseTo(0.1);
|
|
expect(arenaDampening(30_000)).toBeCloseTo(0.15);
|
|
expect(arenaDampening(540_000)).toBe(1);
|
|
});
|
|
|
|
it("uses full, half, quarter, immune DR and resets after fifteen seconds", () => {
|
|
expect(arenaDrDuration(8_000, 0, 0).durationMs).toBe(8_000);
|
|
expect(arenaDrDuration(8_000, 1, 0).durationMs).toBe(4_000);
|
|
expect(arenaDrDuration(8_000, 2, 0).durationMs).toBe(2_000);
|
|
expect(arenaDrDuration(8_000, 3, 0).durationMs).toBe(0);
|
|
expect(arenaDrDuration(8_000, 3, 15_000).durationMs).toBe(8_000);
|
|
});
|
|
});
|