From f7a77b0b661b5cda70ddc65a0468c2fc556ea5b9 Mon Sep 17 00:00:00 2001 From: Jeremy Scheff Date: Wed, 2 Oct 2024 14:25:02 -0400 Subject: [PATCH] Schedule is more compact with series now, so pitchers should start every 5 days, not every 6 --- .../GameSim.baseball/getStartingPitcher.ts | 25 +++++++------------ src/worker/core/game/play.ts | 2 +- 2 files changed, 10 insertions(+), 17 deletions(-) diff --git a/src/worker/core/GameSim.baseball/getStartingPitcher.ts b/src/worker/core/GameSim.baseball/getStartingPitcher.ts index 0e619576ba..9c39b71ad2 100644 --- a/src/worker/core/GameSim.baseball/getStartingPitcher.ts +++ b/src/worker/core/GameSim.baseball/getStartingPitcher.ts @@ -16,16 +16,11 @@ export const getStartingPitcher = ( const playoffs = g.get("phase") === PHASE.PLAYOFFS; // First pass - look for starting pitcher with no fatigue - let firstFound; for (let i = 0; i < pitchers.length; i++) { const p = pitchers[i]; - if ((p.pFatigue === 0 || (playoffs && p.pFatigue < 30)) && !p.injured) { - // Add some randomness, to get lower starters some extra starts - if (playoffs || Math.random() < 0.8) { - return p; - } - - firstFound = p; + const pFatigue = p.pFatigue ?? 0; + if ((pFatigue === 0 || (playoffs && pFatigue < 30)) && !p.injured) { + return p; } if (i === NUM_STARTING_PITCHERS - 1) { @@ -33,15 +28,11 @@ export const getStartingPitcher = ( } } - if (firstFound) { - // If randomness didn't turn up another candidate - return firstFound; - } - // Second pass - reliever with no fatigue for (let i = CLOSER_INDEX + 1; i < pitchers.length; i++) { const p = pitchers[i]; - if (p.pFatigue === 0 && !p.injured) { + const pFatigue = p.pFatigue ?? 0; + if (pFatigue === 0 && !p.injured) { return p; } } @@ -49,7 +40,8 @@ export const getStartingPitcher = ( // Third pass - look for slightly tired starting pitcher for (let i = 0; i < pitchers.length; i++) { const p = pitchers[i]; - if (p.pFatigue <= 30 && !p.injured) { + const pFatigue = p.pFatigue ?? 0; + if (pFatigue <= 30 && !p.injured) { return p; } @@ -61,7 +53,8 @@ export const getStartingPitcher = ( // Fourth pass - tired reliever for (let i = CLOSER_INDEX + 1; i < pitchers.length; i++) { const p = pitchers[i]; - if (p.pFatigue <= 30 && !p.injured) { + const pFatigue = p.pFatigue ?? 0; + if (pFatigue <= 30 && !p.injured) { return p; } } diff --git a/src/worker/core/game/play.ts b/src/worker/core/game/play.ts index 802f24cc00..d9d4ad2882 100644 --- a/src/worker/core/game/play.ts +++ b/src/worker/core/game/play.ts @@ -178,7 +178,7 @@ const play = async ( p.pFatigue = helpers.bound( p.pFatigue - P_FATIGUE_DAILY_REDUCTION, 0, - 100, + 80, ); changed = true; }