Skip to content

Add an upgrade plan: solve for tiers you are about to buy - #4

Merged
OGMods merged 1 commit into
mainfrom
upgrade-plan
Sep 30, 2026
Merged

OGMods merged 1 commit into
mainfrom
upgrade-plan

Conversation

@OGMods

@OGMods OGMods commented Sep 30, 2026 •

Copy link
Copy Markdown
Owner

Summary

Players asked to solve for an upgrade they are about to buy without having to rebuild afterwards. This adds an upgrade plan: up to three upgrades in buying order. A run solves for the tiers at the end of the plan, and every layout it keeps must also run at today's tiers and after each step. The layout comes back at today's tiers, so what is on screen is what can be built now.

It is optimal only at the last step. Until every upgrade is bought, the layout keeps room for what is coming and makes less power than a plain solve. The dialog says so up front.

Why

Measured over the eight maps (8s solves, two seeds, four progression stages), an upgrade can break a standing layout, and which way depends on the role:

Upgrade Layout solved for today, after the upgrade Layout solved for the target, today
Reactor overheats every time (0–66% of its power left) runs
Generator often overheats often overheats
Cooler runs, 49–72% of a fresh target solve overheats every time

A layout solved under a plan never overheated at any step, in any run. It reached 97–100% of the best target power for generator upgrades and ~100% for reactor ones, at 57–98% of today's best power. Cooler upgrades gain nothing: the best layout that also runs today is today's layout. The order matters: requiring every buying order kept 31–59% of the target power, a fixed order 59–99%. So the plan is ordered.

Changes

  • Solver (@reactor2/solver): SolveOptions.upgradePlan. Every point where the search accepts a layout as stable also requires it to run at each plan step (best record, repair, composition, pruning, right-sizing, tied layouts, stabilize). The search also builds a starting layout from today's roster; without that, cooler plans came out far worse. resolveUpgradePlan turns the ordered steps into a target plus the rosters along the way, skipping steps already bought.
  • Worker path: the resolved plan crosses to the island workers.
  • Setup: a row at the top of the Buildings tab opens the plan dialog. Its picker lists only unlocked buildings with a level left to buy (strongest first, with icons). Each step has tier buttons and up/down reordering, and each building card marks its planned tier with a dashed outline.
  • Readout: an "After upgrades" line for any board on screen, including solves found without the plan and the player's own board. It names the first step that would overheat the layout. Buildings idle today but needed after the plan are listed as "Kept for upgrades" rather than Idle.
  • State: under a plan, runs are compared on power after the plan. Each solve records which plan it was searched under (resultPlanKey), and the plan is kept out of the stored-solve signature, so editing it does not discard other islands' saved solves.
  • Docs: docs/SOLVER.md (design note and measurements), the folder CLAUDE.md guides, README.

Testing

  • npm test: 854 passing, 25 of them new. They cover the resolver, stability at every step on three plans, evaluatePlan, ranking by power after the plan, and the dialog's plan actions. Without a plan, the same solves overheat, so the step-stability tests have teeth.
  • npm run fixtures regenerates byte for byte; the path without a plan is unchanged.
  • npm run check and npm run knip are clean.
  • Driven in the dev server at desktop and phone width: plan dialog, a run under a plan (1.46T today / 2.18T after the upgrade, nothing overheating), and the warning on a layout solved without the plan (7 buildings overheat at Quantum Reactor Lv. 4).

List up to three upgrades in buying order and a run solves for the tiers
at the end of the plan, while every layout it keeps also runs at today's
tiers and after each step. The layout comes back at today's tiers, so
what is on screen is what can be built now. It is optimal only at the
last step: until every upgrade is bought, the layout keeps room for what
is coming and makes less power than a plain solve.

- Solver: SolveOptions.upgradePlan holds each kept layout to the plan's
  rosters at every gate that admits a layout (best record, repair,
  composition, pruning, right-sizing, ties, stabilize), and seeds from
  today's roster as well as the target's. No plan, no change: the
  fixtures regenerate byte for byte.
- resolveUpgradePlan turns the ordered steps into a target and the
  rosters along the way, skipping steps already bought.
- Setup: a row at the top of the Buildings tab opens the plan dialog.
  Its picker offers only unlocked buildings with a tier left to buy,
  steps are reordered in place, and each roster card marks its planned
  tier.
- Readout: an "After upgrades" line for any board on screen, naming the
  first step that would overheat it; buildings idle today but needed
  after the plan are listed as "Kept for upgrades" rather than Idle.
- Under a plan, runs are compared on power after the plan. The plan is
  recorded per solve rather than folded into the solve signature, so
  editing it does not discard stored solves.
@OGMods
OGMods merged commit dc3e5bd into main Sep 30, 2026
3 checks passed
@OGMods
OGMods deleted the upgrade-plan branch September 30, 2026 14:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant