Skip to content

AnYejun/KnicksIn5

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

An AI-designed play runs against a reactive defense

🏀 KnicksIn5

An AI draws up the play to win the Knicks the chip in 5 — then proves it beats the defense.

Describe a situation in words. An LLM designs the set play. A possession simulator runs it against a reactive defense, rates the players, and Monte-Carlos the odds. If the play doesn't get an open look, it fails — and the AI fixes it.

Natural language can't hold a basketball play — five bodies moving in space and time, reading each other. That's why coaches use diagrams. So we give the LLM a play language and a simulator that scores it, and let it design tactics that actually work — not ones that merely sound good.

The trick (and why an LLM can do this at all): designing a play is hard, but checking one is cheap. The LLM proposes; the simulation disposes.

How it works

  1. A play is a small language — five routes, screens, passes, a shot, on a court measured in feet. (the grammar)
  2. The defense is a reactive agent — man coverage that stays between its man and the rim, fights over screens (a screen costs it a beat), and sags in drop coverage. The defense is the verifier: a play that doesn't create an open look fails.
  3. Players are rated — shooting by zone, handle, passing, screening, speed. Who takes the shot matters: an elite shooter converts the same open look far more often.
  4. Monte Carlo gives the odds — the possession is run hundreds of times with stochastic make/miss, steals, and defender-reaction noise → an expected points and a scoring probability, robust to luck.
  5. Monte Carlo search makes the tactic emerge — perturb the shot timing and spot, keep what raises the probability. The LLM proposes the structure; the search refines the execution.

The dagger, verified

Game 5, up 3-1. A pick-and-roll vs drop coverage into a pull-up 3 — self-corrected against the simulator until it's a dagger:

step result
authored pull-up EV 0.65 — defender 2.6ft away, contested → poor look
better timing 0.92 — open 3.9ft, ok
too aggressive open 6.1ft but an illegal (too-fast) route — caught
fixed EV 1.12, a wide-open legal 3
Monte Carlo (elite shooter, 800 sims) scores ~49%, EV 1.47
MC search EV 1.54, openness 6.1 → 7.6ft — the tactic tightened itself

Knicks in 5. 🏆

Run it

No build, no dependencies — just open it:

python3 -m http.server 8000
open http://localhost:8000/            # click ▶ run to watch the possession

Drive it from the console:

PROM.apply(play)            // simulate a play, returns EV + Monte-Carlo odds
PHALANX.monteCarlo(500)     // scoring probability over 500 stochastic runs
PHALANX.optimize(80, 150)   // search the execution to raise the odds

The play language (excerpt)

{
  "title": "Knicks in 5 — the Game 5 dagger",
  "defense": "drop",
  "players": [
    { "id": "1", "rt": { "three": 0.85, "hnd": 0.86 },
      "route": [[0,[25,31]], [0.7,[25.8,28.4]], [1.45,[34,30.6]]] },
    { "id": "5", "rt": { "scr": 0.82 },
      "route": [[0,[25,24]], [0.7,[26.9,27.9]], [1.3,[27.1,27.6]], [2.0,[23,16]]] }
  ],
  "screens": [ { "by": "5", "on": "1", "t": 0.9 } ],
  "ball": { "start": "1", "shot": { "t": 1.45, "by": "1" } }
}

Honest boundary

This beats this defensive model — a decent reactive man defense — not necessarily an NBA defense. Real-defense validity needs proprietary tracking data. The whole game is the fidelity of the sim + defensive policy; that's the interesting frontier. Roadmap: help defense + rotations, switch/zone, off-ball reads, possession-EV calibrated to real data, defender difficulty tiers.

Not affiliated with the New York Knicks or the NBA. A fan project — for the love of the game (and of watching an AI find the open shot).


KnicksIn5 is one instance of a broader pattern — giving an LLM a language for things natural language can't hold, plus a deterministic engine that verifies them. More on that soon.

About

An AI draws up the play to win the Knicks the chip in 5 — then proves it beats the defense. A basketball-tactics language + possession simulator + Monte Carlo. (fan project)

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors