Spaces:
Paused
Paused
Commit History
-
Fix the three engine defects the 3D client reported (#92, #93, #94)
Claude +1: Claude Opus 5Unverified signatureAll three were found from outside — alma92350/3D-SpaceExploration-RTS vendors engine/ byte-for-byte — and filed unverified against this repo's suite, because that session could not clone it. All three reproduce here. The full suite is green (2519), typecheck clean, and each fix carries a test that fails without it. #92 — a world fought over did not round-trip its market prices. createMarket derives every raw commodity's price from its share of ALL nodes, and runs exactly twice: at creation, and on load. Wreck/crater nodes are pushed onto the map DURING play and the loader restores them before recomputing, so the reload derived the book from a bigger node set than the live one. Since the share is a fraction of the total, every raw commodity moved, not just the debris's own. Skip wreck and crater nodes — the same exclusion worldHasCommodity already applies. No live behaviour change (there is no debris at creation) and no save-format change. #93 — galaxyStatus reported income 0 for a co…96c6d29
-
Odyssey: bound the living galaxy to 3 seed-drawn background worlds
Claude +1: Claude Opus 5Unverified signaturecreateGalaxy instantiated and simulated all 11 worlds from turn one. It now brings up the start seat plus a pseudo-random draw of BACKGROUND_WORLDS (3) others — backgroundWorldIds, keyed on the galaxy seed and the start world from its own distinctly-seeded stream, returned in fixed roster order so the background scheduler and every galaxy-wide scan read exactly as before. Which neighbours are alive is now part of what a seed means; same seed still replays the same galaxy. The rest of the roster stays DORMANT: still on the starmap, still jumpable, still a full skirmish map — built in on arrival (jumpCapital already did this for a never-visited destination) and simulating from then on like any world you leave behind. addPlanet now honours a standing claim when it builds a world in, so a dormant world the faction-spread sweep claimed flies those colours when the player finally lands on it. Three paths assumed every world's state existed, and are fixed here: - initiateJump treated a mis…b88cc9c
-
Close the guard gaps behind the last three bugs; withdraw one review finding
Claude +1: Claude Opus 4.8Unverified signatureFindings 4, 5 and 8 of docs/code-review-2026-08.md, plus a correction to 7. #8 tools/ ships to the browser but was outside the purity guard. boot.js imports tools/selfplay.js; competition.js, competitionWorker.js and playerFingerprint.js import tools/duelCore.js and tools/genome.js. So three "Node bench" files run in a browser Worker and decide the outcomes that become persisted Elo ratings, while the purity scan only ever walked engine/ and what engine/ imports — structurally identical code guarded on one side of a directory line and unguarded on the other. The review said moving the files was "simplest and better". Measuring first showed otherwise: 30+ prose references across engine/, README and docs would have had to move with them, for no safety gain. Extended the scan instead, and DERIVED the extra roots by walking out from index.html (plus the Worker entry, whose `new Worker(new URL(...))` edge no import walk can see) so a fourth file pulled into the app tomorrow is covered the…021c865
-
Get CI green, and make the AI's opponent belief fade the way it says it does
Claude +1: Claude Opus 4.8Unverified signatureActs on the first three findings of docs/code-review-2026-08.md. CI has been red since 2026-08-05 and two PRs merged through it. Two causes, both fixed here: - competitionLedger.js had two wrong JSDoc signatures. addRosterEntry never declared the `genome` field its body reads and writes (the RosterEntry typedef omitted it too), and recordCompetition typed its match rows as bare `object`, so every row.aName / row.winner / row.margin read in the file was an error the moment a checker looked. Adds a real CompetitionResultRow typedef and narrows the one ternary TypeScript was widening to `string`. - CI installed TypeScript unpinned via `npx --package typescript`, so the same tree reported 2 errors under 5.7 and 21 under 7.0.2 — a green commit could go red overnight with no code change. The invocation is pinned to 5.7.2; the compiler still stays out of package.json, it is just no longer a moving target. Verified clean on both 5.7.2 and latest. The third is a real behavi…15f3a03 -
Phase 4: the adaptation POLICY is evolvable, not just its constants
Claude +1: Claude Opus 5Unverified signatureFive genes in a linkage group of their own -- punishPosture and punishConfidence (when to call an opponent greedy, and how much evidence to demand before acting), adaptRateMult and adaptBandMult (how twitchy or stubborn the stance is), defenceSwingMult (how far the stance swings investment). They are one module because they interact strongly with each other and weakly with everything else, which is precisely the condition module-wise crossover exists for: a low evidence bar paired with a twitchy rate is a completely different opponent from either alone, and a child should inherit that pairing intact rather than half of it. Every one is read through a `?? default` at its use site, so an absent value is exactly the shipped behaviour and the search needs no engine change to explore them -- the same property that made a candidate AI JSON in the first place. This is the difference between breeding a fixed BUILD and breeding a reactive POLICY, and it is what lets MAP-Elites eventually spre…4f42c67 -
Phases 2-3: the AI answers what it reads
Claude +1: Claude Opus 5Unverified signaturePHASE 2 -- the raid stops being a metronome. It fired on `waveCount % RAID_EVERY` and only on Hard: harassment on a schedule, regardless of whether harassment was the right answer. It now ALSO fires when the read says the enemy is visibly investing in economy over defence and enough of them has been scouted to act on it. That is harassment as a response: punish greed, and specifically punish the hoarder docs/ai-evolution-design.md found winning by never committing its army. An opponent that can be SEEN to be undefended should not be safe -- which removes that degenerate strategy structurally instead of penalising turtling inside a fitness function, where evolution would just route around it. The read is deliberately not gated on controller.micro. Reacting to what you scouted is ordinary competence, not the unit-level micro Hard buys, and an Easy/Medium AI that never once punishes a greedy opening is the passivity the bench keeps measuring. PHASE 3 -- a damped stance. posture is far t…5d60e36 -
Phase 1: the AI gets a belief about its opponent
Claude +1: Claude Opus 5Unverified signatureengine/aiIntel.js. Every other reactive read in the AI answers a question about right now -- are there enemies at my base, how many can I see, what do they field most -- and none of them survives losing sight of the enemy, because entity sighting goes through the LIVE fog layer. Kill the scout and the AI's picture of its opponent is empty, and it has no way to know it. This is the other kind of knowledge: what sort of game the opponent is playing. It persists between sightings and decays when unrefreshed. It is the first piece of AI state that can be WRONG -- everything else is a fact about the current frame -- and that is the point. An opponent model you can deceive is what makes scouting worth its cost and killing the scout a real counter-play. Three numbers, and they are three for a reason: mil / eco ore-value of what has been SEEN, split by whether it shoots posture mil / (mil + eco): 0 is a pure economy game, 1 is a pure war game confidence how much has been see…2991d58
-
Phase 5 (spectate): watch an AI-vs-AI match live, at 1x-8x
Claude +1: Claude Opus 4.8Unverified signaturedocs/competitions-and-elo.md Phase 5, the spectate half. Replay-from-the-ledger and Season stay open. Observer Mode was one `if` away from supporting this, and that is all it took: enterObserverMode's `if (!game.galaxy) return` became `if (!game.galaxy && !game.spectateMatch) return`, with spectateId falling back to the state's own planetId. The camera path, input.js's seven delegation points, observedState()'s existing game.state fallback and boot.js's render swap were already general and are untouched — the Odyssey observer tests are the safety net that the galaxy path did not move. Where Observer Mode is OFFERED stays exactly two places: an Odyssey, and a match the human is not playing. An ordinary skirmish is still refused; revealing its fog would just be a cheat. A WATCHED MATCH IS EXHIBITION ONLY, deliberately. Every rated result in this system is a pairing — side-swapped, multi-seed, replicate-parity swapAsym — because a single unswapped match is confounded by the seat edge se…450f6c1
-
Archetype lookup: reject reserved keys instead of resolving to Object.prototype
Claude +1: Claude Opus 5Unverified signaturePhase 2's own final-check pass found this on its own initiative: createAiController's opts.archetype resolution and competition.js's buildJob/shapeRosterRow used a truthy `ARCHETYPES[key]` bracket-access. For a plain object, "__proto__" is always truthy and resolves to the object's own prototype rather than "not a real key" -- so an archetype key of "__proto__" silently became Object.prototype instead of falling back as documented, and "constructor"/"prototype" hit the same inherited-property hazard. Not reachable through the shipped UI today (the Archetype picker only offers real keys, and competitionLedger.js's own roster guard already blocks a hostile value from ever being persisted), but a real contract violation in two exported, reusable functions -- exactly the class of latent bug this effort has been careful to close at the source rather than leave for a future caller to trip over (see the same-name Elo collision fixed in Phase 1, and the roster forbidden-name guard added earli…c0f45f5 -
Phase 2 (part 2): roster + persistent ladder wired into Quick Duel, archetype threaded end-to-end
Claude +1: Claude Sonnet 5Unverified signatureTurns Phase 1's one-off Quick Duel into the persistent competition mode docs/competitions-and-elo.md Phase 2 describes: Quick Duel / Roster / Standings, one coherent mode behind a small tab row, all three reading and writing the SAME competitionLedger.js ledger. THE KEY UX CHANGE: ad-hoc, free-typed entrants are retired. Each Quick Duel entrant is now either picked "From Roster" (a <select> of competitionLedger's current roster) or drafted "New Entrant" (name + strategy + archetype + faction) -- a new draft joins the roster, via addRosterEntry, the instant startDuel() actually commits to running (after buildJob's own validation passes, before the Worker spins up), never on a keystroke, so an abandoned draft never pollutes the roster. A finished duel's rows are folded into the ledger for the pinned difficulty bracket via recordCompetition alone -- no second, hand-rolled elo.js applySeries call in competition.js. The results view's old "Elo isn't saved" line is gone, replaced by "Elo up…628afc1 -
Phase 2 (part 1): per-entrant archetype override (D3) and the competition ledger (D8)
Claude +1: Claude Sonnet 5Unverified signatureengine/state.js's createAiController(planetId, opts) gains an optional opts.archetype: a STRING KEY into engine/aiArchetypes.js's ARCHETYPES table, resolved via ARCHETYPES[opts.archetype] when valid, falling back to archetypeFor(planetId) exactly as before otherwise -- every existing call site (none of which pass it) stays byte-identical. This is what lets a future competition entrant carry its own doctrine instead of both seats sharing whatever temperament the world hands out ("Rusher vs Turtle" becomes a real matchup). elo.js gains a small additive PROVISIONAL_GAMES=10 export (INITIAL_RATING's own precedent) so kFactor and the new ledger's standings read-back share one constant instead of two copies of the number 10. New root-level competitionLedger.js implements D8: a versioned, sanitized, untrusted-input-hardened roster + per-bracket Elo ladder, mirroring engine/persist.js's sanitizeSave/cleanEntity discipline deliberately, not by analogy -- an exact-match COMPETITION_VERSION gate…925767d -
Setup: a 150 Population cap rung, for frame rate
Claude +1: Claude Opus 5Unverified signatureRaising the Odyssey worker crew made neighbours genuinely develop, and a developed neighbour is a lot of entities. Measured on the heaviest case it now produces -- ferros/aggressive, 60 sim-minutes, timing ONE sim-minute at minute 60 so the cost is measured at full size: popCap 150 supply 150/150 units 100 buildings 39 650ms (92x realtime) popCap 200 supply 200/200 units 129 buildings 43 920ms (65x realtime) popCap 300 supply 300/300 units 184 buildings 56 1420ms (42x realtime) popCap Max supply 1221/1233 units 563 buildings 166 8080ms (7x realtime) 150 is ~12x cheaper to simulate than uncapped. It belongs below 200 because it is a PERFORMANCE option, not a balance one: the cap bounds both sides' armies and the housing that feeds them (engine/aiEconomy.js stops raising Habitats once the raw building total reaches the ceiling), so it is the only dial that bounds total entity count directly. Purely a new value in an existing row -- suppl…695bde6
-
AI: give the Odyssey economy something to bootstrap from
Claude +1: Claude Opus 5Unverified signatureRan the four shipped strategies against EACH OTHER (`ailab duel --candidates`, 6 worlds x 2 seeds x both owner slots, Medium and Hard) instead of against a scripted sparring bot. Economic won both brackets outright -- 71% at Medium, 68% at Hard -- and Aggressive came LAST at Medium on 25W-47L. The solo sweep says the same thing from the other side: on ferros, the same Economist archetype reaches development 3 under `default` and 27 under `economic`. One cause, visible twice. aiEconomy.js sizes the Odyssey worker target as `archetype x strategy x difficulty + industryCount * 2`, and the only term that grows during a session is a reward for industry the AI has to already be rich enough to have built. On a strategy that also spends freely on units -- default and aggressive, which galaxy.js hands to roughly half the galaxy -- unit production takes every ore first, industry is never funded, the target never grows, and the loop never starts. Confirmed by a single-dial diagnostic rather than…bc8dc44 -
Tier 3f: split the selection panel's derived state out of its DOM
Claude +1: Claude Opus 5Unverified signaturehudSelection.js was 2242 lines. The natural seam is not "which panel" but "derive vs render": panelSignature is the panel's entire reactivity model — it decides whether renderSelectionPanel rebuilds AT ALL, so a panel whose own state contributes no term to it silently never redraws, which is exactly what left the Freight Lane and Colony Policy controls inert. A model that load-bearing should be readable without scrolling past 800 lines of button construction. hudPanelSignature.js takes panelSignature and the derivations it shares with the renderers — factoryStatus, loadableComs, countByType, summaryRowLabel, counterInfo and the hoisted cost/counter tables — because both sides call them and the two must never drift. It imports no DOM and no hud.js, so unlike the panel itself it is a genuine leaf: drivable from a test, outside the hud/hudSelection import cycle. hudSelection.js drops to 1915 lines with the panel's output byte-identical, which the golden lock added in the previous commit …97f3bdf -
Tier 3c: the AI's found-a-building protocol, and its decision predicates
Claude +1: Claude Opus 5Unverified signatureThirteen sites across aiEconomy.js and aiIndustry.js hand-rolled the same four steps to found a building — findPlacement, canAct, issueBuild, spend — and two of those four fail silently when dropped. Omit `spend` and the AI founds buildings for free, its APM dial quietly no longer throttling it; omit `canAct` and it ignores the budget outright. Neither shows up as a crash, and neither moves a determinism fingerprint on the default archetype, because the default AI has `apm == null` and both calls are then no-ops. Only the APM-limited difficulties and self-play can see the difference — and five of the thirteen sites were already relying on a `canAct` in the guard three lines up rather than at the call itself. aiCommon.js gains tryBuild/tryBuildAt, and the thirteen sites become one line each. The builder stays a parameter rather than baked in: two sites (the Habitat and the first Barracks) have always founded with workers[0] instead of the nearest free worker, so they pass [workers[0]] …ca9c751 -
Tier 3b: rank formation slots per cluster, not globally
Claude +1: Claude Opus 5Unverified signatureDESIGN QUESTION: should range-layering rank per cluster or globally? PER CLUSTER. formationSlots deliberately gives each spatial cluster its own sub-formation — "spaced by each cluster's own footprint so sub-formations can't overlap" — and clusterUnits promises it "preserves each unit's relative position". rankSlotsByRange then re-paired GLOBALLY: it sorted ALL followers by weapon range against ALL slots by forwardness, with no cluster awareness in either half. Two armies far apart therefore cross-swapped sub-formations and each walked the extra distance to the other's slots. The resulting shape was still correct, which is why this reads as pathing jank rather than as two features disagreeing. Ranking per cluster honours both at once: each cluster keeps its members, and each is internally range-layered, which is the entire point of the layering. Two things the work corrected in me rather than in the code: Clustering the FOLLOWERS was wrong — excluding the leader first splits its own…cdae5f9 -
Tier 3a: haul.js's four phase machines, and the save-version coupling
Claude +1: Claude Opus 5Unverified signatureDESIGN QUESTION ANSWERED FIRST, as this tier requires: is the collection-point banking asymmetry intentional? updateHaul banks through nearestGatherDrop, so a gatherer's load can land in a collection-point freighter parked near the seam, while service and ferry returns bank at the Command Center and walk past such a ship. The call: the asymmetry STAYS, and is now documented at the site. A collection point is a GATHERING depot — issueSetCollectPoint anchors a freighter to catch mining output, and assignShuttle exists to run it home in bulk. Routing factory output and leftover ferry cargo through it would consume the hold the gather flow needs, add a second hop for goods usually already near the base, and move every multi-base Odyssey replay, for a convenience gain nobody asked for. Written down so it reads as a decision rather than as an accident of four separately-written machines. With that settled, the structural work: Unknown phases no longer wedge a unit. Each machine is a chain…492ec35 -
Tier 2b: four correctness fixes with a wider blast radius
Claude +1: Claude Opus 5Unverified signatureA yield-multiplied deposit could overfill a collection-point hold. The clamp was applied to the RAW quantity moved and the bonus to the CREDITED quantity, so a PARTIAL deposit landed more than fits — reproduced at 251 into a 250 hold at the Logistics Network's 1.25x. It breaks the hold's capacity and "a save round-trips identically" at once, because persist.js truncates the excess on load: continuing a game stopped being the same as saving and continuing it. That second half is invisible to every replay test, since both runs agree until someone saves. haul.js's own depositToFreighter never had the asymmetry — it moves and credits the same number — and gather.js now does the same. garrisonSlots' corrective pull-back never converged. Its header claims it "keeps the WHOLE parked group, not just its middle, inside the radius", but the anchor is pulled back RADIALLY while the farthest slot is an off-axis grid CORNER, so max|slot - cc| is not a linear function of the ring radius and one pas…2b50b54 -
Tier 2a: collapse the cross-module duplicates, pin the tie-breaks
Claude +1: Claude Opus 5Unverified signatureradiusOf existed THREE times in engine/ and bomb.js's comment asserted the copies were "the same". They were not: only bomb.js's handled a building, by reading the instance radius state.js stamps at construction; movement.js and formation.js returned the magic constant 9 for any building — while movement.js is a // @ts-check'ed file whose JSDoc advertises @param {Unit|Building}. The type layer was actively telling callers a Building was supported on a path that silently under-sized it, which is the exact class of bug MAX_UNIT_RADIUS exists to prevent and which no determinism test can see, being wrong-but-stable on every seed. One shared helper now lives in colliders.js, which already reasoned about def.radius and b.radius. Consolidating it surfaced a real subtlety the plan didn't predict: keying on `kind` alone broke formation.js, whose callers are frequently unit-shaped literals carrying no `kind` field at all. The helper resolves by TYPE first, with a comment recording why. clamp a…e847942 -
Tier 1, step 4e: clear autoTarget on a plain move order (A13)
Claude +1: Claude Opus 5Unverified signatureOn its own commit because it MOVES THE REPLAY: separation spacing feeds back into positions. updateCombat returns before the acquisition block on a plain move, and that block is the only place in the whole engine that writes autoTarget — so the field was unreachable-for-clearing for the entire duration of a move. engine/separation.js's isCombatMode reads it as a combat-mode register, which directly contradicts its own doc comment two lines above: "Deliberately NOT combat mode for a plain 'move' order… a stale autoTarget/focusId reads as still-combat-mode for one tick too long — harmless." It was not one tick; it was permanent. The consequence is that a unit pulled out of a fight with Move — which combat.js's own header calls the way to disengage, so this is the common case, not an edge — kept the tight combat packing (minDist x1) instead of the padded idle spacing (x1.2) that SEPARATION_PAD_MULT exists to give it. A small, permanent, silent divergence from the stated contract, in the…3589155 -
Tier 1, step 4d: two dead HUD controls and a hidden build button (A6, A10)
Claude +1: Claude Opus 5Unverified signatureA6 — renderSelectionPanel returns early unless its rebuild signature string changed, and that 141-line expression contained no lane or colony-policy term at all. Every handler in both panels is `mutate(); renderHUD();`, so the simulation changed and the UI stayed frozen on the old value: commodity chips, "+ New Lane", disband, and every Colony Policy control read as no-ops. Worse than inert — a control that appears to do nothing invites a second click, which silently toggles the change back. Auto-sell is the sharpest case: it gates a whole sub-section, so turning it on was supposed to reveal the per-commodity floor rows and didn't. Assign/Release only ever appeared to work by accident, because they set u.laneId, which perturbs the Spaceport manifest term. Both terms are now in the signature, kept coarse (ids and values, not per-frame floats) so they can't churn a rebuild every tick — a rebuild mid-click is the dropped-click hazard the guard exists for. Three tests, each verified red, …ec9801f -
Tier 1, step 4c: the AI bench lies, and an owner-parametric leak (A9, A12)
Claude +1: Claude Opus 5Unverified signatureA9 — runDuel applied BOTH candidates' overrides into the same live STRATEGIES table, and applyOverrides merges rather than replaces. Two variants of the same dial under the same strategy key — which is the natural A/B tuning workflow — collapsed into one Frankenstein row belonging to neither candidate, played by BOTH seats, and reported a perfectly normal-looking winner that was pure seat/seed noise. This is the function every AI tuning decision runs through, and `search --tournament-against` scores every dial value through it, so a session could "promote" a change that was never actually measured. A collision is now refused up front with a message naming the shared key and suggesting distinct ones; round-robin and Swiss inherit the check across every pair before a long tournament starts rather than partway through. A12 — effectiveMix threads `owner` into prereqsMet but called plannedMix with none, and plannedMix called strategyFor(state)/difficultyFor(state), both of which default to…5853645 -
Tier 1, step 4a: five reproduced engine defects (A1-A4, A11)
Claude +1: Claude Opus 5Unverified signatureEvery fix was preceded by a test verified red against the real behaviour, and the two A1 tests were additionally re-run with the fix reverted to prove they bite rather than passing incidentally. A1 — keepFollowingLeader decided its leader was gone by hp alone. A follow-leader order holds a live object REFERENCE, and two removal paths delete a unit that is still at full hp: deployColonyShip and updateUnitRecycle. Escorting a colony ship to a site and deploying it is the canonical Odyssey play, and it left both escorts permanently pinned to a ship no longer in state.units, orbiting its frozen last position. They still accept new direct orders, so it read as "my units randomly stopped obeying the formation". The check now asks the state, not the field. (escort orders were always immune — escortSlot resolves through state.units.get every tick.) A2 — the squad-release loop spliced the array it was iterating. A for...of iterator is index-based, so every splice skipped the next element: dro…0da037f -
Tier 1, step 3: harden the save load path past the entity boundary
Claude +1: Claude Opus 5Unverified signaturecleanEntity coerces ~20 per-field cases well, and that discipline stopped exactly at the entity boundary. Three whole sub-objects reachable from an Odyssey save were written into live state verbatim, two lane invariants the runtime enforces were dropped on load, and one field was never persisted at all. Sixteen new tests, every one verified red first. A5 — galaxy.rivalAscended, the idempotency latch the code names as such, was never written to the payload (zero hits in persist.js, zero across test/). Continuing a campaign silently undid a Rival Gate ascension: with the Gate razed the "permanent" stance ceiling could never be re-applied, because checkRivalGate can only re-latch by finding a completed Gate; with it standing, the ascension event re-fired on every Continue. Autosave runs every 12 s. Additive, so no GALAXY_SAVE_VERSION bump. B1 — the diplomacy block was `{ ...createDiplomacy(), ...P.diplomacy }`, the untrusted object winning every key. engine/diplomacy.js's clamp() is the…0974cb1 -
Tier 1, step 2b: expand // @ts-check coverage from 10 files to 20 (D3)
Claude +1: Claude Opus 5Unverified signatureAdopted in the order docs/code-improvement-tiers.md sets out, cheapest and highest bug-class value first: supply, aiCommon, colliders, victory, production, scout, the three AI leaves (aiStrategy, aiDifficulty, aiArchetypes), and finally persist.js — the prize, because every save field is a State/Unit/Building field read by name, so annotating it makes save-shape drift a check-time error. Each file's exports are annotated with the shared typedefs, not just given the pragma: per the guard added in the previous commit, a pragma without annotations checks nothing. Doing it surfaced three more genuine drifts in engine/types.js, all found by the checker rather than by reading: - Building.rally was typed {x, y} but carries nodeId — the rally-to-resource feature, where a rally dropped on a live node makes a produced unit spawn already mining (engine/production.js). - Building.queue entries were typed {unitType, progress} but carry `alt`, which records that a job was charged the unit's…7e764b0 -
Tier 1, step 2: make the type layer real (D1, D2, D4)
Claude +1: Claude Opus 5Unverified signatureengine/types.js had drifted from the shapes it claims to model. A tsc probe against the seven typedefs returned 20 errors and zero on the control fields: State.popCap, State.playerAi AiState.strategy, AiState.lastThreatAt Galaxy.lanes, Galaxy.laneSeq GalaxySettings.startId, GalaxySettings.popCap Diplomacy.provokedAt/goodwill/request/lastFavorBucket Order.tx/ty/explore/patrol Archetype.wantsRefinery/turretCount/maxBarracks/garrison State.playerAi is the central field of the self-play feature, left undeclared by the very commit that added it. The drift was invisible because every factory assigns to a const before returning, so TypeScript never runs an excess-property check — and it actively BLOCKED adoption: annotating one function in engine/supply.js with @param {State} produced three errors in correct code, which teaches contributors to distrust the checker. All 20 now resolve; typecheck stays clean. Added a Lane typedef (createLane's real shape) and declared the lazil…6db3533
-
Make the AI controller owner-parametric: true two-sided self-play
Claude +1: Claude Sonnet 5Unverified signaturerunAI(state, dt, owner = "ai") and every AI phase module now resolve their controller, opponent, and fog grid from `owner` instead of hardcoding "ai"/ state.fogAI — 100% backward compatible (every pre-existing call site keeps the default and behaves byte-for-byte as before). A new, independently configured controller slot (state.playerAi, null by default) lets a second real AI drive the "player" seat in a skirmish, headless-only (tools/ selfplay.js) — nothing in setup.js/boot.js/the shipped game changed. Independent adversarial review (fairness lens + correctness lens) caught a real bug before this was accepted: Hard difficulty's economic edge (hardEdge) was seeded onto state.players.ai only, never a self-play "player" controller configured for Hard. Fixed via seedDifficultyEdge (engine/state.js), called for "player" once state.playerAi exists. engine/persist.js's save/load extension is purely additive (no SAVE_VERSION bump) — old saves round-trip unaffected. Co-Authored-By: Claude …916c3ad
-
Disable jump-time cargo auto-fill: an empty ship carries nothing
Claude +1: Claude Sonnet 5Unverified signatureAn empty freighter used to auto-fill from the origin stockpile most-valuable-first (machinery, then electronics, alloys, spice, metals) on every jump - a "produce here, sell there" convenience default. It actively worked against a deliberate there-and-back haul: load goods, jump, unload at the destination, then jump straight back before reloading, and the now-empty ship would eagerly scoop up whatever was just delivered and carry it right back - a delivery silently undone, easily mistaken for a duplication bug. loadCargo (engine/galaxy.js) now delivers exactly what was hand-loaded per ship (loadFreighter/unloadFreighter) and nothing else. Freight Lanes (runLanes) and the freighter panel's own "Auto-load" button are untouched - both are separate, still-explicit uses of cargoManifest's most-valuable-first pick, not the silent jump-time trigger this removes. Updated the Spaceport panel's cargo preview to show what's actually aboard the staged ships rather than a hypothetical auto-fill p…f6a4da9 -
Stand the AI's parked garrison in a grid at the base's own skirt
Claude +1: Claude Sonnet 5Unverified signatureIdle home-army units were dispersed to one of only 3 fixed points on a 220-radius ring, round-robin assigned — so any garrison bigger than 3 had multiple units ordered to the exact same coordinate. A shared destination never lets separation.js and movement.js's arrival test both settle: the units keep walking toward the shared point while separation keeps shoving them back apart, forever, which reads as Brownian jitter in a supposedly "parked" army. The fixed radius also had no awareness of the base's actual size, so a well-fortified base could put the ring inside its own turret line instead of outside it. disperseGarrison now gives every unit its own slot via formationSlots (engine/formation.js — the same primitive the player's own move/hold-formation orders already use), so no two units ever share a target point. The grid is anchored past the base's real built footprint (baseFootprintRadius, scanning this CC's own nearby buildings) rather than a flat constant, with a corrective pass…c920e1c -
Let sustained ore surplus lift the Odyssey AI's standing-army cap
Claude +1: Claude Sonnet 5Unverified signatureEconomic and Force-Parity strategies cap their standing army at a tiny floor (matchFloor/standingArmyCap, typically 3) and never lift it once a background world has nowhere left to expand and every Barracks slot is already full — the existing surplus sinks (extra Barracks, extra colony ships) are both finite, but a living-galaxy world's income never stops. Verified against an uploaded Odyssey save where several never-visited neighbours (kybernet, helix, forge, glacius) had fully researched every upgrade, built out to their Barracks/CC caps, and were still sitting on 8,000-34,000+ idle ore behind a permanently frozen 3-unit garrison. standingArmyCap() now adds an ore-surplus bonus (same SURPLUS_STEP escalation shape as the existing Barracks/colony-ship sinks) on top of the strategy's own floor, Odyssey-only. Manually probed before/after on five world/strategy combinations: worlds with genuine ore surplus that were previously frozen at the floor for a full 120-sim-minute run now keep gr…ac44339 -
Disperse the AI's idle home army across garrison stations
Claude +1: Claude Sonnet 5Unverified signaturePreviously the AI's home army - whatever wasn't committed to a strike - sat clumped at whichever building's rally point produced it, one engagement away from losing its entire standing defense. Add disperseGarrison: each of the AI's own Command Centers (home, plus any same-map expansion) now claims a ring of stations around itself and spreads its nearby idle units evenly across them, instead of everyone sharing one point. Units already fighting (autoTarget/focusId set) are left alone mid-engagement, and a unit too far from every Command Center (a stray deep in contested territory) is left exactly where it stands rather than yanked home. Stations stay within the existing defend-recall radius, so an attack on one still triggers the normal army recall. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LPPqQ7gWGMtrSJDB7nCy1r8c4f62d -
Halve AI actions-per-minute for background (non-active) worlds
Claude +1: Claude Sonnet 5Unverified signatureA background colony (state.background, engine/galaxy.js) is a world the player isn't currently seated on. Nobody's actively watching it, so it now accrues its APM action budget at half its configured rate instead of managing its economy as briskly as the player's active seat. The attack/defense commit itself stays fully exempt from the budget, so a background world under attack still always throws whatever it has and the game always resolves. state.ai.apm itself is never rewritten - only the accrual rate (and its derived burst cap) changes. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LPPqQ7gWGMtrSJDB7nCy1re818247 -
Widen idle and formation unit spacing by 20%
ClaudeUnverified signatureTwo independent levers, kept deliberately separate so they don't compound into each other: - engine/formation.js: COARSENESS (the existing formation-spacing multiplier, introduced by a prior "units sat too close together" pass at 1.15x) goes to 1.38 — a further +20% on top of that. It already cascades correctly through every formation shape (grid, line, wedge, circle) and nested formation-of-formations spacing with no other change needed. - engine/separation.js: idle/general collision separation had no padding at all before this — minDist was the bare sum of two units' radii, so same-owner units at rest settled shoulder to shoulder. Added a standalone SEPARATION_PAD_MULT (1.2), applied only to minDist here, NOT to entities.js's own radius fields — touching radius directly would have also fed formation.js's own spacing calculation (which reads that same field), compounding the two changes to 44% instead of two clean, independent 20% increases. Combat packing is…873d661 -
Add a configurable population cap (200/250/300/Max) for both sides
ClaudeUnverified signatureNo hard ceiling existed before this — supplyCap (engine/supply.js) was purely additive from completed buildings (Command Center +10, Habitat +8), unbounded above. Added a new setup.js option, Population cap, alongside the existing economy dials (Faction/Resources), offered in both Skirmish and Odyssey (the two modes with a real economy) — Max (the default) is byte-identical to today's always-uncapped behavior. - engine/supply.js: split the old supplyCap into buildingSupplyCap (the raw, unclamped additive total) and a new supplyCap that clamps it to state.popCap when set. Every existing caller (production.js's enforcement gate, hud.js's display) keeps calling supplyCap unchanged and transparently gets the clamped behavior. - state.popCap threads through createGameState, boot.js's startGame AND startOdyssey, and engine/galaxy.js's createGalaxy/addPlanet — applied unconditionally to every world (active seat and background neighbours alike, exactly like sizeMult/resourceMult…dadc0b2 -
Let gather/wreckage/rig-haul workers bank into a nearby collection-point Hauler
ClaudeUnverified signaturenearestGatherDrop (engine/gather.js) — the single function that decides where a gathering worker, a wreck-salvager (same gather order, just targeting a node tagged wreck: true), and a Plasma Rig's own hauler (engine/haul.js's updateHaul reuses this exact function) all walk to deposit their load — only ever scanned buildings. A landed, player- toggled COLLECTION-POINT Hauler/Freighter (unit.collectPoint) was already a valid collection point for a FACTORY's backlog (the Ferry mechanic), but completely invisible to any of these three job types: directing a worker onto a mining site or a wreck, with a Hauler parked right next to it, still sent every trip all the way to the Command Center. nearestGatherDrop now also scans state.units for an owned, collectPoint-flagged, cargo-capable unit with room to spare — same eligibility assignFerry's own scan already uses — and returns whichever candidate (building or unit) is closer. Both call sites' deposit step now branch on the result: a building …e5f7f16
-
Bound applySeparation's per-unit candidate scan under pathological density
Claude +1: Claude Sonnet 5Unverified signatureA user-reported CPU spike traced to a background world whose idle AI army had grown to 642 same-owner units piled on one rally point. applySeparation's grid-accelerated neighbor query scales with local density, not army size, so a single tick there ran up to ~94ms with ~15ms in separation alone. applySeparation now caps candidates resolved per unit per call (MAX_SEPARATION_NEIGHBORS), with the scan window rotating by the unit's grid index and the simulation tick so a huge pile still fully settles over time instead of some units being permanently skipped. Ordinary battles never approach the cap. Cuts the profiled world's separation phase by ~74% and its total tick by ~40%. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01RvU3W5f2Vnk2oFKpud9jmTee2be58 -
P8 Combat Depth: uphill concealment (real LOS), veterancy ranks, tiered-kill event fields
Claude +1: Claude Sonnet 5Unverified signatureThree combat.js-anchored proposals from Phase 8 of the improvement roadmap, landed as one coherent pass through engine/fog.js and engine/combat.js since a later team's fog-render-perf work depends on this cell/fog-grid contract: 1. Real LOS pass (docs/improvement-proposals.md lines 831-839): fog.js's reveal() now takes the source's own terrain (one sampleTerrain call per source) and caps how far a NON-high-ground source reveals a high-ground CELL at UPHILL_FRAC (0.55) of its normal sight radius — a mesa is a stat pad AND a genuine blind spot for anyone still in the lowland. combat.js's nearestEnemy/spreadEnemy apply the identical rule to acquisition via a shared highGroundCap helper, so a unit can't shell a held ridge blind just because its raw aggro happens to reach that far. Both fog grids (state.fog, state.fogAI) inherit this through the same updateFog/reveal path — no AI-side code needed, verified with a dedicated symmetry test. 2. Veterancy ranks (line…8f89fac -
Conquest overrides a stale rival-Gate ascension, not the other way around
Claude +1: Claude Sonnet 5Unverified signatureThe Domination-Faction-Memory team flagged this cross-team interaction in their own report rather than guessing at a fix outside their file scope: Rival Gate ascension ceils a world's stance permanently at PEACE_THRESHOLD via a direct mutation reapplied every scan, while Domination with teeth floors a pacified world's stance target at Neutral inside updateDiplomacy's slower drift. On a world that both ascends and is later personally pacified by the player, the ceiling's every-scan reassertion always wins the raw stance value between the floor's drift ticks — so razing an ascended neighbour's Command Center would have no visible effect on its stance, forever. That reads as broken: conquest is the more direct, more recent player action, and should win. Confirmed the bug with a red test first (200 interleaved updateDiplomacy/checkRivalGate scans after pacifying an already- ascended world never lift its stance past the ceiling), then fixed it by skipping the ceiling's application and reap…9300cbe -
Domination occupation dividend: pacified worlds pay a small credits/sec
Claude +1: Claude Sonnet 5Unverified signatureOptional half of docs/improvement-proposals.md 657-665 ("Domination with teeth"): a pacified world now contributes PACIFIED_INCOME (0.1 credits/sec, ~6/min) in sweepColonies, additive on top of any ordinary building-based colony income and independent of whether the player ever founded a colony there — conquest alone is worth a small, modest annuity, deliberately far below what a single well-built colony can pay at its cap (COLONY_INCOME_PER_BUILDING * COLONY_INCOME_CAP = 1.8/s). Tests in test/domination.test.js: a pacified world with zero player buildings still banks credits, and an unpacified background world pays nothing. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>3ac784d -
Domination with teeth + Faction memory, tuned as one stance-pipeline system
Claude +1: Claude Sonnet 5Unverified signatureTwo proposals that rewrite the same checkDomination/updateDiplomacy pipeline, shipped together per the roadmap's explicit call ("ship together as one stance-pipeline change"). Domination with teeth (docs/improvement-proposals.md 657-665): checkDomination now stamps state.diplomacy.pacified = true on a freshly-razed world (it already holds that state in its loop). updateDiplomacy floors that world's drift target at APPEASE_FLOOR (Neutral) permanently, placed AFTER the existing Gate-finale clause so pacifying a world is specifically what exempts it from finale mobilization — conquest becomes the military counter to your own Gate's provocation. deserializeGalaxy re-stamps the flag on load for saves that already carry galaxy.pacified from before this flag existed. Faction memory (docs/improvement-proposals.md 519-527): pacifying a world now echoes a bounded, one-time stance penalty (FACTION_ECHO_PENALTY) onto every OTHER unpacified world of the same faction (matched by claim or AI factio…051d7f7 -
Revert accidental inclusion of concurrent team's in-progress work
Claude +1: Claude Sonnet 5Unverified signatureThe previous commit's `git add` swept in engine/diplomacy.js, engine/galaxy.js (the domination/faction-memory hunks), engine/persist.js, engine/types.js, test/diplomacy.test.js, and test/domination.test.js — all in-progress, uncommitted work from the concurrently-running P7-Domination-Faction-Memory team, not mine to commit. This restores those six files to their prior (pre-that-commit) content; their own working-tree changes are reapplied on top afterward, unaffected, for that team to commit under its own history. No functional change to the rival-Gate feature itself. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>40dc0e6 -
Extend determinism coverage to the rival Gate's charge
Claude +1: Claude Sonnet 5Unverified signaturetest/_helpers.js's entitySnapshot now folds a wonder's `charge` into its per-building fingerprint tuple, so a charge-path float divergence (player's or a rival's) actually surfaces in a determinism comparison instead of only in the coarser rounded-count galaxy-persist checks. New determinism-roster case: two galaxies from the same seed, each with an AI-owned rival Gate mid-charge on a background world, replay byte-identical through stepGalaxy's real background-world schedule. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>2f96159 -
Add the rival Gate: a neighbour races its own Antimatter Gate
Claude +1: Claude Sonnet 5Unverified signatureMerges two independently-written proposals describing the same feature (Defense twin "the galaxy's strongest faction races its own wonder" + AI twin "a fully-teched neighbour races its own Antimatter Gate") into one mechanism. Reconciled trigger (engine/aiIndustry.js rivalGateEligible/RIVAL_GATE_BUFFER): the Strategic tier standing (Antimatter Forge + AI Foundry + Torpedo Works, antimatter_gate's own `requires`) AND a banked strategic-goods buffer, gated to Hard difficulty OR a wantsDeepIndustry temperament. Every qualifying AI world raises its own Gate independently, self-contained in its own think cycle. Explicitly re-checks the Easy strategicCeiling flag so the invariant holds by construction, not just by the accident of the chain never reaching that far. engine/wonder.js generalizes chargingPlayerWonder into chargingWonderOf(state, owner), with chargingPlayerWonder now a thin delegate (existing diplomacy.js/aiMilitary.js callers unaffected) — updateWonder needed no changes at all…f75beff -
Add Easy strategic ceiling (Phase 7 prerequisite)
Claude +1: Claude Sonnet 5Unverified signatureAn Easy neighbour's INDUSTRY_CHAIN climb and RESEARCH_ORDER research now stop before antimatterforge/'antimatter' Containment, withholding the whole Strategic tier (and everything downstream of it: Star Dock, Leviathan, Helium Bomb, Plasma Rig, and — this phase — a rival Antimatter Gate) from Easy neighbours, the same argument aiDifficulty.js already makes for withholding marketAccess. Medium and Hard are unaffected. This lands first because the rival-Gate workstream depends on it: an Easy neighbour must never be able to reach antimatter_gate's prereqs to begin with. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>5e33d82 -
Colony economy rework: Freight Lanes + Colony standing orders
Claude +1: Claude Sonnet 5Unverified signatureThe roadmap calls these "two halves of a single colony-economy rework" and they share the same background-scheduler plumbing in stepGalaxy/persist.js, so they land together as designed, even though each is its own mechanic: Freight Lanes (engine/galaxy.js): a galaxy.lanes array. At a Spaceport, assign parked freighters to a LANE (source -> destination, commodity filter) via createLane/assignShipToLane. Every LANE_PERIOD galaxy ticks, runLanes moves min(assigned cargoHold, filtered stock) straight from the source world's treasury to the destination's — a standing investment, not free teleportation: assigned ships are revalidated every cycle (still alive, still parked within JUMP_LOAD_RADIUS of a source Spaceport) and are excluded from stagedRiders/jumpManifestAll so they never get swept off on a jump. UI: a lane-management panel on the Spaceport selection panel (hudSelection.js) plus a read-only summary on the starmap. Colony standing orders (new engine/colonyPolicy.js): a per-planet …84220dc -
AI: let a developer archetype walk the trade-industry branch too
Claude +1: Claude Sonnet 5Unverified signatureOptional half of the trade-industry-branch proposal: extends engine/aiIndustry.js's INDUSTRY_CHAIN and RESEARCH_ORDER (both already flat, world-independent priority lists - a Reactor is built regardless of local deposits too) so a developer AI can also reach the Chemical Plant/Fabricator and their chemistry/consumerfab tech, not just the existing military/Gate spine. chemplant slots in right after datacenter (it needs no Smelter/ metallurgy at all, so prereqsMet alone decides when it's actually reachable); fabricator slots in right after assembler (its recipe needs alloys, so it can only ever win the priority race once the metallurgy branch has already supplied one). chemistry/consumerfab mirror that placement in RESEARCH_ORDER, right after metallurgy. This does not add new per-world conditionality (e.g. prioritizing the branch specifically on biomass-rich worlds) - every other entry in both arrays is equally world-blind, and a smarter heuristic is a reasonable follow-up left for lat…b55016a -
Promote legacy consumer-goods recipes into a trade-industry branch
Claude +1: Claude Sonnet 5Unverified signatureWires the exact "tech + wiring" promotion path data.js's own LIVE-vs-LEGACY comment reserves for the 'chem' and 'consumer' recipes (both already existed in data.js RECIPES, untouched here): - engine/techtree.js: two new TECHS nodes. `chemistry` is a genuine second ROOT of the tree (no `requires` at all, same shape as `metallurgy`) so it opens a truly separate branch rather than a leaf off the existing ore->metals->alloys spine. `consumerfab` is gated on `chemistry` alone, not metallurgy. - engine/entities.js: two new odysseyOnly BUILDINGS, following the Smelter/Assembly Plant recipe/dropOff/prodRate idiom exactly. The Chemical Plant (recipe 'chem': biomass+power -> chemicals) requires only the chemistry tech - no Smelter, no metallurgy. The Fabricator (recipe 'consumer': alloys+chemicals+power -> goods) is where the branch MEETS the metallurgy spine - it requires the Assembly Plant (for alloys) plus the Chemical Plant and its own tech, the same two-supplying-bui…26b3c86 -
Spaceport tiers discount new-world jump fuel
Claude +1: Claude Sonnet 5Unverified signatureThe pad's tier no longer only lifts more fleet per jump (SPACEPORT_CAPACITY) — it now cuts new-world fuel too, via a FUEL_DISCOUNT_BY_TIER table (x1.0 / x0.85 / x0.7) applied in jumpCost's distance-scaled branch only. Free return jumps to a world you already hold are untouched. Both existing cost-preview call sites (hudSelection.js's Spaceport panel, starmap.js's jump hint) already call jumpCost so they pick up the discount automatically; extended their copy text to say so. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>8624f8e -
Doctrine depth redesign: Assault tempo verbs + Bulwark regen (Tier 2 & 3, merged)
Claude +1: Claude Sonnet 5Unverified signatureMerges the two related doctrine-depth proposals (docs/improvement-proposals.md lines 217-225 and 433-441) into one coherent redesign per Phase 5 of docs/improvement-roadmap.md, instead of shipping them as separate tickets. Assault: overchargedCore (Tier 2) now also grants chaseSpeedMult 1.1 ("combat drive" - closes on an acquired target ~10% faster, applied only in updateCombat's chase branch). A new Arsenal-gated capstone, Overdrive Actuators (Tier 3, requires ["overchargedCore","arsenal"]), grants attackCooldownMult 0.9 - a distinct tempo identity, applied at both cooldown- reset sites (updateCombat's main attack path and updateWorkerCombat), but deliberately NOT at updateBuildingCombat's - this is the army's tempo upgrade, not a base-defense buff. Bulwark: THE RECONCILIATION - proposal 1's Tier-2 grant and proposal 2's Tier-3 capstone both independently proposed "out-of-combat hp regen" as Bulwark's identity. Rather than ship two separately-tracked regen fields, this is one mechan…f0783f6 -
Static-defense ladder: Bastille, Aegis Bastion, Plasma Torpedo Battery
Claude +1: Claude Sonnet 5Unverified signatureShips as one rationalized tier per docs/improvement-roadmap.md Phase 4, not three unrelated additions: all three new structures are tuned against a single shared invariant (every siege unit — Breacher 150, Colossus 185, Leviathan 200 — must still strictly outrange every static-defense structure added here, with one deliberate, documented exception at the top of the ladder), and land together so that invariant is verified once, holistically, rather than three separate times. - Bastille (engine/entities.js): a second, Foundry-gated static-defense tier — hp 600, attack 32, cooldown 1.4, range 115 (deliberately under even the plain turret's 130: a tankier, shorter-ranged brawler, not a sniper). Same combat stat field names the turret uses, so combat.js's updateBuildingCombat needed zero changes to run it. Wired into hudSelection.js's skirmish build list and the Odyssey GROUPS/alwaysShow sets alongside the turret, and into aiEconomy.js's fortify block: the AI's second fortifi…45b37a3