Fix lint errors in AutoRacingSimulator: no-non-null-assertion + no-console
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
06a011f0ed
commit
1bb70a06c3
2 changed files with 19 additions and 7 deletions
|
|
@ -108,8 +108,11 @@ describe("AutoRacingSimulator", () => {
|
|||
|
||||
it("heavy favourite ranks first more often than long shots", async () => {
|
||||
const results = await new AutoRacingSimulator(F1_RACE_POINTS, "f1").simulate("s1");
|
||||
const favourite = results.find((r) => r.participantId === "d1")!;
|
||||
const longShot = results.find((r) => r.participantId === "d2")!;
|
||||
const favourite = results.find((r) => r.participantId === "d1");
|
||||
const longShot = results.find((r) => r.participantId === "d2");
|
||||
expect(favourite).toBeDefined();
|
||||
expect(longShot).toBeDefined();
|
||||
if (!favourite || !longShot) return;
|
||||
expect(favourite.probabilities.probFirst).toBeGreaterThan(longShot.probabilities.probFirst);
|
||||
});
|
||||
|
||||
|
|
@ -178,8 +181,11 @@ describe("AutoRacingSimulator", () => {
|
|||
]);
|
||||
|
||||
const results = await new AutoRacingSimulator(F1_RACE_POINTS, "f1").simulate("s1");
|
||||
const leader = results.find((r) => r.participantId === "d1")!;
|
||||
const distant = results.find((r) => r.participantId === "d2")!;
|
||||
const leader = results.find((r) => r.participantId === "d1");
|
||||
const distant = results.find((r) => r.participantId === "d2");
|
||||
expect(leader).toBeDefined();
|
||||
expect(distant).toBeDefined();
|
||||
if (!leader || !distant) return;
|
||||
// Standings signal should dominate: d1's massive points lead wins out
|
||||
expect(leader.probabilities.probFirst).toBeGreaterThan(distant.probabilities.probFirst);
|
||||
});
|
||||
|
|
@ -192,8 +198,11 @@ describe("AutoRacingSimulator", () => {
|
|||
makeEv("d2", 1000),
|
||||
]);
|
||||
const results = await new AutoRacingSimulator(F1_RACE_POINTS, "f1").simulate("s1");
|
||||
const fav = results.find((r) => r.participantId === "d1")!;
|
||||
const longShot = results.find((r) => r.participantId === "d2")!;
|
||||
const fav = results.find((r) => r.participantId === "d1");
|
||||
const longShot = results.find((r) => r.participantId === "d2");
|
||||
expect(fav).toBeDefined();
|
||||
expect(longShot).toBeDefined();
|
||||
if (!fav || !longShot) return;
|
||||
// Without standings, odds-favoured driver should still rank higher
|
||||
expect(fav.probabilities.probFirst).toBeGreaterThan(longShot.probabilities.probFirst);
|
||||
});
|
||||
|
|
@ -223,7 +232,9 @@ describe("AutoRacingSimulator", () => {
|
|||
|
||||
const results = await new AutoRacingSimulator(F1_RACE_POINTS, "f1").simulate("s1");
|
||||
// d5 should win championships at a non-trivial rate given their strong odds weight
|
||||
const d5 = results.find((r) => r.participantId === "d5")!;
|
||||
const d5 = results.find((r) => r.participantId === "d5");
|
||||
expect(d5).toBeDefined();
|
||||
if (!d5) return;
|
||||
expect(d5.probabilities.probFirst).toBeGreaterThan(0.1);
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -200,6 +200,7 @@ export class AutoRacingSimulator implements Simulator {
|
|||
// share-of-points weight and silently degrade the blending accuracy.
|
||||
const participantsWithPoints = ids.filter((id) => currentPointsMap.has(id));
|
||||
if (participantsWithPoints.length < ids.length) {
|
||||
// eslint-disable-next-line no-console
|
||||
console.warn(
|
||||
`[AutoRacingSimulator] ${ids.length - participantsWithPoints.length} participant(s) missing from standings for season ${sportsSeasonId} — blending may be inaccurate`
|
||||
);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue