Skip to content

PhantomGM

The best lineup in every Fantrax league at once, including the leagues that cap your games

PhantomGM is a manager's command deck for Fantrax basketball leagues, and we are building it at FBI Basketball as a team. It plans every lineup in every league, moves players on and off injured reserve, suggests pickups and bids, and can set lineups by itself every half hour during game hours. Adds and drops always wait for the manager.

It is in testing with FBI's admins before it opens to members.

Built with

  • Next.js 16
  • React 19
  • TypeScript
  • Supabase
  • Fantrax
  • Vercel Cron

Coming soon. FBI's admins are testing it before it opens to members.

The screens

Redrawn for this site from the real product, in its own type and colours, with sample data.

TonightThe plan for one head-to-head matchup: the chance to win with the planned lineup against the one Fantrax holds now, each category's odds, and the moves that get there. The week is played out twice from projections and the per-category chances are combined into the matchup's; it is a work in progress.
AutopilotThe autopilot card from Settings. A scheduled job re-plans every league that has autopilot on, every 30 minutes through game time and leaves a starter alone once his game has tipped.
Activity logEvery lineup saved to Fantrax: who went in, who came out and why, and what the save did to the chance of winning the matchup.
LeaguesEvery Fantrax league on the account, with autopilot switched on or off for each one and a second switch to keep a league off the Tonight screen.
WordmarkPhantomGM's blackletter wordmark, in the gradient cut for dark grounds. It is used apart from the logo.
App iconThe logo as the app icon: a hooded phantom dribbling a ball whose seams are cut out, drawn as a flat vector in six violets.

Everything it does

49 features in 7 areas, written from the code.

Connecting Fantrax

Fantrax has no write key, so the app works through two separate connections and never asks for a password. It is a work in progress that only FBI admins can open.

7 features

Read-only league list
A Fantrax User Secret ID lists the manager's leagues and their team in each. It is the same connection the H2H Planner uses, so a manager who already connected there has nothing to do.
Lineup access by pasted session
The app does not sign in to Fantrax for anyone. The manager signs in on fantrax.com and pastes the sign-in cookie, which is checked against Fantrax before it is kept.
Guided wizard
One action per step, each with a drawing of the Fantrax screen it refers to, then a live check on what is pasted. On a phone the lineup-access step is a single screen that says to do it once on a laptop or desktop.
Forgiving paste
The paste box accepts the bare cookie, a whole Cookie header, a copied cURL command or a cookie-export JSON. It refuses a paste that lacks Fantrax's remember-me cookie.
Preview before connecting
Without a session every plan still shows, built from Fantrax's published data. Locks, injury tags and roster room are left out there, and every save is refused.
Signed-out banner
When Fantrax ends the session, every screen carries a red banner saying autopilot is paused, with a Reconnect button. The top bar and sidebar stop saying autopilot is on.
Disconnect
Lineup access can be removed from Settings at any time, separately from the read-only league list.

Tonight

The home screen: every league at a glance, and one button that sets them all.

7 features

The night's figures
How many leagues are set, how many need moves, the moves planned, and the win chance the plans add across all matchups. While Fantrax is still being read the labels are already there and each figure says it is reading.
A card per league
Status, the manager's team with its record and place, the format, the win chance with and without the plan, tonight's starters, the first three moves and the best pickup. Cards side by side share their rows, so the same section sits at the same height on each.
Moves with reasons
Each move says who, where to, and why: how many games he has, no game, Fantrax lists him out, games saved under a cap. A start also names the categories it helps most in this matchup.
Run autopilot
One press plans each league shown on Tonight fresh and saves it, three leagues at a time, each league's days in date order. Closing the sheet mid-run lets the leagues already started finish and starts no new one.
Step log
Each league in the run shows a log of what the server answered: the plan, then every save with Fantrax's message if it refused. Lines read out of the single plan answer are tagged "found", so nothing is shown as progress that was not a real request.
Run without a session
Until a session exists, the Run controls in the tab bar and sidebar keep their place, read as unavailable and say why. A run started while another is saving is told to try again.
Install card
Steps to add the app to a home screen, written for the browser and phone in use, with a picker for the others. It can be put off for a week or dismissed for good.

The league screen

One league in full, for a manager who wants to see why.

8 features

Win chance, now and planned
The same week is played twice, once with the lineups Fantrax holds and once with the plan. The screen shows both chances and the difference in percentage points.
Category by category
In a categories league each category has its own chance to be won, now in grey and with the plan in colour. A category the plan leaves between 35% and 65% is flagged as a swing.
Lineup for each day
A tab per day in the planning window, with a dot on the days that have moves. Each slot shows the planned starter, his opponent, his chance to play when it is in doubt, and who Fantrax has there now when that differs.
The week as a grid
Each player with a game in the window or an active slot against every day: a planned start, a bench game, a new start ringed, a game he is not expected to play striped. The last column counts each player's starts.
Games caps
In a league that caps games per slot, each slot shows games played, games the plan uses and the maximum.
This period or the next
A switch plans the following scoring period instead, so next week can be set before it starts.
Notes a manager can act on
A commissioner lock, a live draft or a slot nobody on the roster can fill is said in a line. Things the manager cannot change are left out.
Per-league autopilot and re-read
The league's own autopilot switch sits at the top, next to a button that reads Fantrax again.

What the planner decides

The rules it follows. The lineup rules are the team's own, and the value of a start comes from FBI's projection engine.

8 features

Valued in the league's own terms
A start is worth what it does in this league: categories weighted by this week's matchup in head-to-head categories, the league's point weights in points leagues, z-scores in roto.
Out players do not start
A player Fantrax lists out or suspended is worth nothing on every planned day and is benched even with nobody to replace him, except in a weekly league that needs every slot filled. Once Fantrax shows him playing, the next run can start him again.
Games banked under caps
Where a slot has a weekly games limit, the whole remaining period is planned at once, so tonight's sit can be what saves a game for a better night. Later days count 2.5% less per day, which leans the plan toward using games early.
Injured reserve, filled
An open IR spot takes the longest absence among the players Fantrax allows into IR, which opens a roster spot. Only absences of a week or more go there.
Injured reserve, rebalanced
When IR is full, an occupant due back within a week swaps with a bench player who is out at least a week longer. An IR player who is expected to play comes back, by swap or into an open roster spot, when starting him improves the lineup.
Leagues that refuse saves over IR
Some leagues reject every lineup while an untagged player sits in IR. The planner records that per league from Fantrax's refusal and clears IR first there.
Minors call-ups
A minor-league player is called up only when the roster has room, the lineup improves and Fantrax's own dry run accepts the move.
Weekly and locked leagues
A weekly-lineup league gets one lineup for the week and is left alone once it tips. Each day is compared with that day's own lineup in Fantrax, since future days are saved separately.

Pickups, claims and bids

Suggested by the app, made only when the manager presses the button.

8 features

Only real pickups
A player is suggested only when the league's pool lists him as a free agent or on waivers and no roster holds him this period or the next. The league is read live for this, not from a cache.
Valued from the day he joins
A pickup counts only for the games after he would join, and the dropped player's games are lost from that day. With an open roster spot nobody is dropped, and under a games cap he counts only for the starts the cap has room for.
Checked with Fantrax first
The top 3 suggestions are asked of Fantrax exactly as the button would send them, and the week is replayed on the answers if a date moved or one was refused. A pickup with no start left this week is not suggested.
Add, Claim or Bid
The button says what will happen: a free agent is an add, a waiver player is a claim, and a league that takes bids gets a bid. The sheet says when it takes effect and how many of his games come after that day.
Suggested bid
A free agent starts at the minimum. Where the league's budget rules are known, which is FBI's own leagues, a waiver player's bid is a share of the budget set by his rest-of-season rank and how much season is left, with step buttons to change it.
Changing the drop, and warnings
The manager can pick a different player to drop, and a Fantrax warning needs a second, explicit press. In a league that looks like a dynasty or keeper league, the sheet warns that the suggested drop is only the player worth least this week.
Pending claims
A placed claim shows in amber where the suggestion was, with the bid, the drop if it wins and when it runs. It can be re-bid or cancelled, and that player is not suggested again.
What it will not do
Autopilot only sets lineups and IR. It never adds, drops or bids by itself, and nothing in the app trades.

Autopilot, Leagues, Activity

Leaving it running, choosing where, and reading back what it did.

6 features

Autopilot switch and day timeline
Settings shows the day's runs as ticks, the ones already past dimmed, a marker at now and the next run in the viewer's own time zone. The times come from the UTC schedule, so they stay right when the clocks change.
Every 30 minutes through game time
Each run re-reads Fantrax and the injury news and saves what changed, so a late scratch is benched on the next run before his tip. A starter whose game has tipped is left alone.
Per-league switches
The Leagues screen lists every league with one switch for autopilot and another to keep the league off Tonight. A hidden league can still be on autopilot.
Last save per league
Each league row says when it was last saved, or that Fantrax refused the last save.
Activity feed
The last 120 saves, grouped by day: who went in and at which slot, who came out and why, IR moves, adds and claims, and what the save added to the win chance. A refused save is listed too, with Fantrax's message.
Totals
Saves and moves across those entries, and how long ago the last run started.

The app itself

A separate app inside the FBI site, with its own brand. It has not launched.

5 features

Installable phone app
It has its own manifest, icon set and start page, apart from the FBI app on the same domain. On a phone it has a bottom tab bar with Run raised in the middle; from 1024 pixels wide a sidebar replaces it.
Offline notice
A one-line strip appears when the device is offline and says autopilot keeps running on the server.
Your name
The name the app greets the manager by can be set in Settings. It changes nothing elsewhere on the site.
Admins only for now
Anyone who is not an FBI admin gets the site's not-found page on every screen, and a 404 from every PhantomGM API route. The only link to it is a tile on the admin dashboard.
Reduced motion
With reduced motion set, the run log shows every line at once and the working indicator stands still.

The math

The formulas are the ones the code runs, and each chart is computed from them.

  1. 01

    Price a start

    A start is worth the player's value per game times his chance of playing. In head-to-head category leagues the value reads the matchup: each category is weighted by how much one more unit moves its win chance this week, so a team already winning rebounds by a mile stops chasing rebounds.

    value = max(base × p(play), 0.25 × replacement × p(play))

    category weight = φ(z) / σ

    Healthy98.5%
    Probable97.0%
    Questionable, 28+ min64.0%
    Questionable58.0%
    Doubtful2.0%
    Out or suspended0.0%
    Chance of playing tonight by injury status. Questionable is 0.64 for a player averaging 28 minutes or more, 0.58 below that.
  2. 02

    Solve the lineup

    Filling slots is an assignment problem: players on one side, slots on the other, every pairing scored. The Hungarian algorithm solves it exactly. Players whose games have started stay locked, a slot a player isn't eligible for costs a billion, and a tiny bonus for his current slot means ties never reshuffle a lineup for nothing.

    cost = −(score + keep bonus)

    ineligible slot = 10⁹

  3. 03

    Plan around games caps

    Some leagues cap how many games each slot can use in a week, which turns tonight's lineup into a question about the whole week. PhantomGM plans the period at once as a min-cost flow and will bench a player who is playing tonight to save a slot's last game for a better night. Each later day is discounted 2.5%.

    1. Source to player-days: cap 1, cost −value
    2. Player-days to slot-days: cap open G slots
    3. Slot-days to slot: cap games left
    4. Slot to sink: cap ∞
    The flow network. Each player-day carries its value as a negative cost, and each slot's capacity is the games it has left.
  4. 04

    Bid

    FAAB bids scale with the player's rank and how much season is left: 12% of the budget for a top 50 player, falling off exponentially to about 2% by rank 150.

    bid = budget × share × clamp(season left, 0.25, 1)

    share = 0.12 × e−(rank − 50) / 55 past rank 50

    Share of the FAAB budget bid, by player rank, with the full season left.

Under the hood

The work nobody using it sees.

  1. 01

    Writing to a site with no write API

    Lineups are saved by replaying the manager's own Fantrax session against the endpoints Fantrax's web app uses. The session is encrypted with AES-256-GCM before it is stored and refreshed in place when Fantrax re-issues a cookie.

  2. 02

    The save path

    Every save reads the period fresh and refuses a stale plan, asks Fantrax for a dry run and refuses on any illegal-roster message, lock or later effective date, then executes, reads the period back and compares every requested spot. A lineup is saved for its own day only and an IR move is saved forward so it holds.

  3. 03

    Lineup assignment

    Players are assigned to slots with the Hungarian algorithm over Fantrax's own eligibility, which finds the lineup with the highest total value. A small bonus keeps a player in the slot he already holds, so equal plans do not shuffle the lineup.

  4. 04

    Games caps as a network flow

    A capped period is one min-cost flow (source to player-day, to slot-day, to the slot's remaining games, to sink) that returns the most valuable set of starts the caps allow across every remaining day.

  5. 05

    Value from the FBI projection engine

    A player's worth on a date comes from the rest-of-season projection, the night's slate and his chance to play, scored through the same assembly the H2H Planner uses. When the roster has IR or minors players it is run a second time with them counted as bench, so those players have a value for IR moves and call-ups.

  6. 06

    Win probability model

    Each side's expected totals are what has been scored plus every planned start's line times his chance to play, with the variance of a game that may not happen included; counting categories use a normal comparison and percentages use made and attempted, both widened by a per-category factor that shrinks as the week is played. The matchup chance is a Poisson-binomial over the category chances: more than half won, a tie split evenly.

  7. 07

    Caps inside the odds

    When the week is played out, a capped slot stops counting once its games run out, in date order. The opponent's side is the engine's projection of his week.

  8. 08

    Scheduling and the hand-off at tip

    A cron runs every 30 minutes from 14:00 to 04:30 UTC, the span NBA tips fall in, for every account with autopilot on and a working stored session. Fantrax marks a starter as locked when his game starts and the planner pins a locked player where he is, so the hand-off needs no clock of its own.

  9. 09

    One run at a time

    A manual run and the cron cannot save for the same manager at once: each checks for an unfinished run started in the last 10 minutes. A signed-out session is marked, and the cron skips that manager until a new one is pasted.

  10. 10

    Unknown is not assumed

    If Fantrax does not answer the caps view, or answers for a different week, that league is stopped for the run and tried again on the next one, 30 minutes later. A player whose pool status is unknown is not treated as free, and a failed IR save stops that league for the run.

  11. 11

    Commissioner locks

    Whether a league is frozen is found with a dry run. The answer is remembered per league and re-checked after 6 hours when locked and 24 hours when not.

  12. 12

    Claims match their preview

    A claim is sent only if Fantrax's answer still matches the preview the manager was shown; otherwise nothing is sent and the new answer is shown. Whether a pickup needs a bid is read from Fantrax's player-details call, and a claim refused for want of a bid comes back asking for one.

  13. 13

    Storage and audit

    Six Postgres tables hold sessions, settings, per-league choices, learned league rules, runs and saves. Every save is a row, accepted or refused, and each autopilot run records the IR picture it saw for every league so a wrong call can be read back.

  14. 14

    Preview port

    The planner talks to Fantrax through one interface. A second implementation answers the same reads from the published API and refuses every write, dry runs included, which is how plans show before lineup access is connected.

  15. 15

    Tests

    76 unit tests in 7 files cover the planner, the Fantrax parsers, IR and pickups, claims, pending claims, bids and the run log. The planning modules are pure functions with no I/O, so they are tested without Fantrax.

  16. 16

    Two apps on one origin

    The FBI site and PhantomGM both install as phone apps from the same domain, so crossing from one to the other forces a full page load and each keeps its own manifest. The installed app's start URL serves a real page that replaces itself with the app or the sign-in, in place of an HTTP redirect.