Implements a Monte Carlo simulator for men's/women's tennis seasons scored on the qualifying_points pattern. Simulates all 4 Grand Slam majors (Australian Open, French Open, Wimbledon, US Open) using surface-specific Elo ratings and ATP/WTA world rankings for seeding. New table: participant_surface_elos — one row per (participant, season) storing worldRanking, eloHard, eloClay, eloGrass. Key design decisions: - Seeding uses ATP/WTA world ranking (not Elo), matching real draw procedure - Top 32 seeded with standard slot placement (1→0, 2→64, 3-4→quarters, etc.) - QP per round with tie-splitting pre-applied: W=20, F=14, SF=9, QF=4, R16=1.5 - Completed majors read actual qualifyingPointsAwarded from eventResults - 10,000 Monte Carlo simulations; column sums naturally 1.0 (no normalization) Admin UI at /admin/sports-seasons/:id/surface-elo: - 5-column grid (Player | Rank | Hard | Clay | Grass) - Bulk import: "Name, ranking, hardElo, clayElo, grassElo" one per line - Fuzzy name matching (bigram Dice coefficient) with "Did you mean?" suggestions - Inline participant creation for unmatched names via useFetcher - Saves Elos and auto-runs simulation on submit Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
24 lines
No EOL
1.2 KiB
SQL
24 lines
No EOL
1.2 KiB
SQL
ALTER TYPE "public"."simulator_type" ADD VALUE 'tennis_qualifying_points';--> statement-breakpoint
|
|
CREATE TABLE IF NOT EXISTS "participant_surface_elos" (
|
|
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
|
|
"participant_id" uuid NOT NULL,
|
|
"sports_season_id" uuid NOT NULL,
|
|
"elo_hard" integer,
|
|
"elo_clay" integer,
|
|
"elo_grass" integer,
|
|
"updated_at" timestamp DEFAULT now() NOT NULL
|
|
);
|
|
--> statement-breakpoint
|
|
DO $$ BEGIN
|
|
ALTER TABLE "participant_surface_elos" ADD CONSTRAINT "participant_surface_elos_participant_id_participants_id_fk" FOREIGN KEY ("participant_id") REFERENCES "public"."participants"("id") ON DELETE cascade ON UPDATE no action;
|
|
EXCEPTION
|
|
WHEN duplicate_object THEN null;
|
|
END $$;
|
|
--> statement-breakpoint
|
|
DO $$ BEGIN
|
|
ALTER TABLE "participant_surface_elos" ADD CONSTRAINT "participant_surface_elos_sports_season_id_sports_seasons_id_fk" FOREIGN KEY ("sports_season_id") REFERENCES "public"."sports_seasons"("id") ON DELETE cascade ON UPDATE no action;
|
|
EXCEPTION
|
|
WHEN duplicate_object THEN null;
|
|
END $$;
|
|
--> statement-breakpoint
|
|
CREATE UNIQUE INDEX IF NOT EXISTS "participant_surface_elos_unique" ON "participant_surface_elos" USING btree ("participant_id","sports_season_id"); |