Harbour City Dynasty
Midnight Shift2-1 · 4th











Free agent · joins today · 3 starts
+2% to win · no drop needed
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
Coming soon. FBI's admins are testing it before it opens to members.
Redrawn for this site from the real product, in its own type and colours, with sample data.
49 features in 7 areas, written from the code.
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
The home screen: every league at a glance, and one button that sets them all.
7 features
One league in full, for a manager who wants to see why.
8 features
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
Suggested by the app, made only when the manager presses the button.
8 features
Leaving it running, choosing where, and reading back what it did.
6 features
A separate app inside the FBI site, with its own brand. It has not launched.
5 features
The formulas are the ones the code runs, and each chart is computed from them.
01
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) / σ
02
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⁹
03
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%.
04
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
The work nobody using it sees.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.