import { NCAABasketballSimulator } from "./ncaa-basketball-simulator";
import type { Simulator, SimulationResult } from "./types";

export function barthagWinProbability(barthagA: number, barthagB: number): number {
  const pA = barthagA * (1 - barthagB);
  const pB = barthagB * (1 - barthagA);
  const total = pA + pB;
  if (total === 0) return 0.5;
  return pA / total;
}

export class NCAAWSimulator implements Simulator {
  private readonly simulator = new NCAABasketballSimulator({
    source: "ncaaw_bracket_rating",
    missingRatingName: "Barthag-like rating",
    selectionRatingDivisor: 0.08,
    winProbability: barthagWinProbability,
  });

  simulate(sportsSeasonId: string): Promise<SimulationResult[]> {
    return this.simulator.simulate(sportsSeasonId);
  }
}
