initial commit

This commit is contained in:
George Powell
2026-03-26 12:11:43 -04:00
commit 9b779598e9
25 changed files with 665 additions and 0 deletions

27
test/testAtBat.ts Normal file
View File

@@ -0,0 +1,27 @@
import type { GameState } from "../types/GameState";
import atBatSimulator from "../game/atBatSimulator";
import { randomTeam } from "./generateFixtures";
const batting = randomTeam();
const fielding = randomTeam();
const initialState: GameState = {
inning: 1,
top: true,
outs: 0,
count: { balls: 0, strikes: 0 },
score: { home: 0, away: 0 },
};
const batter = batting.battingLineup[batting.batterIndex]!;
const pitcher = fielding.fieldingLineup.pitcher;
const catcher = fielding.fieldingLineup.c;
console.log(`Batter: ${batter.firstname} ${batter.lastname} (batting: ${batter.skillset.batting.toFixed(2)})`);
console.log(`Pitcher: ${pitcher.firstname} ${pitcher.lastname} (armStrength: ${pitcher.skillset.pitching.armStrength.toFixed(2)})`);
console.log(`Catcher: ${catcher.firstname} ${catcher.lastname}`);
console.log("---");
const result = atBatSimulator(batter, catcher, pitcher, initialState);
console.log("Result state:", result);