Spaces:
Paused
Paused
Commit History
-
Make ice coolant an actual ongoing cost, not just a stockpile checkβ
Claude +1: Claude Sonnet 5Unverified signatureiceCoolantMult was eligibility-only: any nonzero ice banked gave the 50% discount forever, for free. Add chargeIceUpkeep, which drains a flat rate of ice from the treasury for as long as a building actually realizes the discount this tick (a factory that ran a batch, a power station that burned fuel, a Rig that completed a dig) β nothing is charged when a building isn't benefiting (paused, starved, stalled). Once the treasury's ice hits zero the discount reverts automatically, clamped so it never goes negative. Updates the HUD's Ice Coolant row copy to reflect that it's draining banked ice, and adds tests covering the drain-per-benefit-tick behavior, the no-charge-when-idle behavior, and the revert-to-full- price behavior once ice runs out. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01RSYr2P7939xnDqRbae5tCG3e3db8e -
Add ice coolant efficiency and a 5% paused-power trickleβ
Claude +1: Claude Sonnet 5Unverified signatureBanked ice now acts as a coolant for the whole industrial base: any owner with ice in the treasury runs recipe-based factories, the Plasma Rig, and the fuel-burning power stations (Reactor / Combustion Generator / Biomass Reactor) at half their normal appetite β half the recipe inputs, half the Rig's nuclear burn per dig, half a power station's fuel burn, and half the grid Power a factory or the Rig draws. It's a flat stockpile check (ice isn't spent), so it's a standing bonus for as long as any is banked. Separately, a paused factory or Plasma Rig no longer frees its whole reserved Power β it idles at a 5% standby trickle instead of 0. Also surfaces both changes in the HUD: a new Ice Coolant status row on the factory/Rig/power-station panels, a live-updating fuel-burn number, and pause tooltips that mention the trickle. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01RSYr2P7939xnDqRbae5tCGeaccb6e -
Rebalance the power stations: 10x cheaper fuel, 50% more Power (#31)β
Unverified signatureThe Reactor/Combustion Generator/Biomass Reactor family was burning through its fuel larder too fast relative to how much Power it granted. For all three: - combust.rate (fuel burned per second) divided by 10 β Reactor 1.2 -> 0.12, Combustion Generator/Biomass Reactor 0.6 -> 0.06. The Reactor still burns at double its smaller siblings' rate, same ratio as before. - energyGrants (Power granted while fuelled) up 50% β Reactor 20 -> 30, Combustion Generator/Biomass Reactor 10 -> 15. The Reactor still grants double its siblings' Power, same ratio as before. Updated stale comments citing the old numbers (entities.js, and a couple of test comments), and two industry.test.js assertions that hardcoded the old 20-Power cap to instead derive their expected values/factory counts from BUILDINGS.reactor.energyGrants, so they don't go stale again the next time these numbers are tuned. Claude-Session: https://claude.ai/code/session_01Q3sL7SnGvLsgSaqoXowTGc Co-authored-by: Claude <norepβ¦5ce9536 -
Let a non-Capital Command Center pack into a Colony Ship to relocate (#29)β
Unverified signatureA Command Center has always been permanently fixed once placed β nothing ever moved a building's x/y. Adds the reverse of the existing Colony Ship -> Command Center deploy (engine/colony.js deployColonyShip): packing a plain CC converts it back into a Colony Ship at its own spot, which the player can then walk anywhere and redeploy with the deploy flow that already exists untouched. - packCommandCenter (engine/colony.js) mirrors deploy's shape exactly β an atomic, instant, pure state mutation (pay a cost, delete the building, spawn the ship), not a multi-tick "building walks" mechanic, since nothing in the engine has ever needed the latter and building has no order/velocity field to hang it on. - Costs 200 ore (PACK_COST) β cheaper than a fresh Colony Ship (500 ore) since it's recycling existing infrastructure, but a real cost. Any queued production is refunded first via the existing cancelProduction. - Refuses a Capital (upgradeToCapital's own doc already says "it never β¦4e88434 -
Split the generalist Worker into category-owning specialists (#28)β
Unverified signatureThe single Worker did everything β mining, founding every building type, hauling, servicing factories, ferrying freighters β across ~22 building types, making its job list unmanageable. Adds three new specialist unit types, each owning construction (and, for Technician, ongoing operation) end-to-end for a building category, mirroring the existing Mender precedent (a proven specialist split with its own tech gate): - Miner: gather-only, no tech gate, cheaper and faster-mining than Worker. - Engineer: builds Infrastructure + Military buildings (Command Center, Habitat, Spaceport, Datacenter, Antimatter Gate; Barracks, Turret, Star Dock) β the buildings with no ongoing haul/service loop. - Technician: builds + hauls/services/ferries Industrial buildings (Refinery, Foundry, Arsenal, the factory chain, power stations, Plasma Rig), gated behind Foundry like Mender. Foundry/Arsenal land here (not Military) because both are forward drop-offs that already need this logistics capabiβ¦340ed0f -
Fix hauler ping-pong loop when its source is itself a drop-off (#27)β
Unverified signatureA Foundry/Refinery/Arsenal is both a haul-able collection point and a valid forward drop-off. Once a worker loaded cargo there, it was also the nearest drop-off (distance ~0, closer than a far-off CC), so updateHaul delivered the load straight back into the pile it just took it from, then reloaded β forever, with zero net progress. nearestGatherDrop now takes an excludeId so updateHaul's "toDrop" phase can exclude the job's own source building from the drop-off search. Co-authored-by: Claude <noreply@anthropic.com>fca5d94 -
Make the Reactor burn radioactives too, refuelled by workers like its siblingsβ
ClaudeUnverified signatureThe original power station stayed free once built while its smaller combust siblings needed a worker-hauled fuel larder β an inconsistency once the Combustion Generator/Biomass Reactor pattern existed. The Reactor now runs on the exact same mechanism: a `combust` fuel list (radioactives), its own local larder (entities.js inputCapOf), filled by a worker SERVICE run (engine/haul.js), burned by updateCombustors β at double the smaller stations' rate, matching its double Power/reach. Merged the Reactor's own HUD panel into the generic fuel-burning-power- station one (hudSelection.js) now that it shares the same mechanic, instead of leaving two separate, now-overlapping panels selecting the same building. Also fixes a real bug this exposed: assignService's "needs its output cleared" check read storeTotal(b) >= storeCapOf(b.type) * ASSIGN_FRACTION, which is true (0 >= 0) for ANY building with no output buffer at all β previously masked because non-recipe buildings were filtered out beforeβ¦39bb807
-
Make the Combustion Generator gas-onlyβ
ClaudeUnverified signatureIt briefly accepted radioactives as an alternate fuel too, but the Combustion Generator burns a combustible gas β Helium-3, not fissile material. Radioactives are dropped from its fuel list; its own local larder (entities.js inputCapOf) now gives gas the whole 80-unit buffer to itself instead of splitting it with a fuel it no longer takes.ff7742b -
Have power stations refuel from a worker-hauled larder, and add the Biomass Reactorβ
ClaudeUnverified signatureThe Combustion Generator used to burn gas or biomass straight out of the treasury, automatically, with no worker involvement at all β unlike every other producer in the Odyssey economy, which draws from a finite local buffer a worker has to physically haul in. Gave it (and its new sibling) the same treatment: fuel now lives in the building's own `input` larder, filled by a worker SERVICE run (engine/haul.js) exactly like a factory's input, and updateCombustors burns from that larder instead of the treasury directly. Split the fuel roster while at it: the Combustion Generator now burns gas (Helium-3) or radioactives; the new Biomass Reactor is its sibling for a biomass-rich claim, same stats, burning biomass alone. Both are ordinary `combust` buildings, so entities.js's per-commodity larder-splitting (inputCapOf) already gives each accepted fuel its own guaranteed slice, same guarantee a multi-input factory recipe gets. Also fixes a bug this surfaced: countLogistics only ever reset thβ¦a7b559b -
Recover a recycled building/unit's full current inventory, not just its cost fractionβ
ClaudeUnverified signatureRecycling only ever refunded a fraction of the entity's original BUILD COST β whatever raw materials or output happened to be sitting in a factory's input larder or output backlog, a freighter's freight hold, or a worker's carried cargo was simply destroyed along with it. That stock was already gathered or produced, not spent constructing the thing, so losing it just because the structure/vehicle carrying it was being scrapped was a bad surprise. recycleValue now merges the cost-based fraction with the entity's full current inventory (at 1:1 value) into one combined bank β the single source of truth for both the actual payout and the HUD's refund preview, so the two can never drift apart.22a180c -
Give each factory input commodity its own larder slice instead of one shared poolβ
ClaudeUnverified signatureA multi-input recipe (Chip Fab: crystals+metals; Torpedo Works: antimatter+ alloys+radioactives; ...) shared ONE pooled input buffer across every real input commodity. Workers over-delivering whichever commodity the treasury happened to have plenty of could fill that whole pool on their own, leaving zero room for whichever OTHER input the recipe was actually starved of β haul.js's inputRoom check always read 0 for it, so it could never be hauled in and the factory stalled forever on an input it could never receive. inputCapOf now splits the larder evenly across a recipe's real (non-energy) inputs, so each gets its own guaranteed slice regardless of how much of another has been delivered. Updated every inputRoom call site to check room per-commodity, the HUD's Larder readout to show each commodity against its own slice, and the save-load clamp to clamp each commodity independently instead of sum-clamping the whole buffer.18d5122 -
Merge pull request #21 from alma92350/claude/haul-nearest-dropoffβ
Unverified signatureLet a hauler deliver to the nearest forward drop-off, not just the Command Center292a250 -
Let a hauler deliver to the nearest forward drop-off, not just the Command Centerβ
ClaudeUnverified signatureA worker hauling a Plasma Rig's (or any producer's) backlog always walked all the way to the Command Center, even with a Refinery/Foundry/Arsenal built right next to it β ignoring the "forward drop-off shortens a distant run" mechanic raw ore-gathering workers already get. updateHaul now picks the nearest place with room to take the load, Command Center or forward drop-off alike, re-checked every tick of the walk so a nearer option that appears (or frees up room) mid-trip is taken immediately instead of only at the moment the load first filled.454fb70 -
Let the player recycle a completed building or unit for part of its cost backβ
ClaudeUnverified signatureSelect any owned, completed building or unit and Recycle it: it stands down in place over roughly half its build time (freely cancellable, no penalty) and refunds 40% of its cost, or 50% for pricier industrial/capital assets (a factory, the Plasma Rig, a Reactor/Generator, a freighter, a Mender) β boosted to 70%/80% (capped) by a new research node in either tech tree (Field Recycling, Logistics doctrine tier 3 in skirmish; Reclamation Engineering at the Datacenter in Odyssey). A Command Center can't be recycled. Persists across save/load, with save-hardening against a tampered file.79c7af7 -
Let idle workers auto-discover a collection-point freighter, and stop ferrying it home themselvesβ
ClaudeUnverified signatureIdle workers now offer to ferry any nearby COLLECTION-POINT freighter with room and a producer worth fetching from (assignFerry), checked ahead of haul/service so a busy rig's hauler slots don't all go to CC-bound workers first. A ferry worker on a collection-point freighter only tops it up now β the freighter's own shuttle run owns the trip home, instead of the worker carrying cargo back to the CC itself. Also fixes nearestBacklogProducer's minFraction=0 path (used by assignShuttle and a ferry worker's replan) treating a fully-drained producer as still "worth waiting for", since storeTotal(b) < cap*0 is never true at exactly zero β this silently blocked a collection-point freighter's last partial load from ever shipping once its feeding producer ran dry.5e0b657 -
Merge pull request #18 from alma92350/claude/freighter-collection-pointβ
Unverified signatureLet workers use a freighter as a collection point, with self-shuttling when full2a1007a -
Let workers use a freighter as a collection point, with self-shuttling when fullβ
Claude +1: Claude Sonnet 5Unverified signatureWorkers can already ferry cargo to/from a landed freighter. This adds a Collection Point toggle (no research needed): once a freighter's hold is full, it drives itself to the nearest Command Center, banks its whole hold, and returns to the spot it was anchored at to keep collecting -- so a freighter parked at a remote claim can act as a self-emptying forward depot instead of needing a worker to carry its load home too. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AdsYZQyGk32n8x3UBiPGup7a847ac -
Let a Reactor be paused, taking it off the power gridβ
Claude +1: Claude Sonnet 5Unverified signatureA Combustion Generator could already be paused; a Reactor had no such toggle and always contributed to the grid once built. Adds the same Pause/Resume control to the Reactor's panel, so a player can take one off the grid by hand -- e.g. to switch a base over to running purely on Combustion Generators (or back) -- without demolishing it. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AdsYZQyGk32n8x3UBiPGup014a4f2 -
Let workers load/unload freighters and add an AI-logistics freighter modeβ
Claude +1: Claude Sonnet 5Unverified signatureWorkers can now physically ferry cargo to and from a landed freighter (right-click it, like assigning a worker to service a building) β the freighter becomes a mobile collection point for nearby production instead of every load detouring through the Command Center. Also adds a new Datacenter research, Autonomous Freight AI, that lets a freighter join the local haul/service logistics chain on its own, like a worker but at its own much larger cargo capacity. Running autonomously burns AI Cores from the treasury while active; out of AI Cores it just pauses in place instead of losing its job or cargo. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AdsYZQyGk32n8x3UBiPGup6f39bc5 -
Add a fuse delay to the Helium Bomb and slow the shockwave further (#12)β
Unverified signatureProximity and the player's own "Detonate Now" command now light a 4-second fuse (BOMB_FUSE_DELAY) instead of detonating on the spot; the actual blast follows once the timer comes due, via a new updateBombFuse tick check. Being attacked stays an instant, unrelated trigger. Disarming a bomb also cuts a lit fuse. The proximity trigger distance (BOMB_DETECT_RANGE) is now tied to BOMB_CORE_RADIUS (1.5x the bomb unit's own radius) instead of a distance past the blast radius, so only a point-blank enemy sets it off. Adds a pulsing amber warning ring + a distinct beep cue while the fuse burns, and slows the shockwave ring's travel by a further 20% for more dramatic pacing. Updates the HUD panel text and persistence (fuseUntil survives save/load, sanitized like armed) accordingly. Co-authored-by: Claude <noreply@anthropic.com>c1ba8ce -
Give the Helium Bomb distance-based damage falloff and a slow shockwave (#11)β
Unverified signatureReplace the flat "erase everything within blast radius" kill with a distance-squared decay of HP loss: entities within BOMB_CORE_RADIUS (1.5x the bomb's own radius) still take a guaranteed-kill hit, but damage tapers off with the square of distance beyond that, reaching zero at BOMB_BLAST_RADIUS. Blast-killed entities still grant no salvage, same as before. Also slows and reworks the detonation VFX into a dramatic, decelerating shockwave ring that crawls out to the true blast radius and cools from a hot core color to ash-grey at the tapering edge, echoing the new damage curve. Updates the HUD panel text and test suite to match. Co-authored-by: Claude <noreply@anthropic.com>33fe16b -
Redefine formation leader as first-selected unit, add persistent follow, speed cap, and drag-to-faceβ
Claude +1: Claude Sonnet 5Unverified signatureReworks the formation system per feedback on PR #9: - Leader is now whichever unit the player selected first (the one others get added to), not a stat-based pick. pickLeader() and layout() in engine/formation.js simply use array order instead of scanning for highest maxHp. - Selecting and moving just the leader now drags along everyone previously grouped with it, with no need to reselect the group. A new persistent "follow-leader" order (engine/commands.js, engine/movement.js, engine/sim.js, engine/combat.js) mirrors the existing escort-order pattern: followers re-seek the leader's live position every tick via object references (unit.squadLeader / leader.squadFollowers), set up by dispatchFormation() and torn down by any direct order that bypasses it (stop, hold, scout, build). - A formation's travel speed is capped to its slowest member so a fast leader can't stretch the group out of shape. dispatchFormation() computes the cap once at issue time and stores iβ¦6648f62 -
Formation shapes, leader positioning, and nested formations for grouped unitsβ
ClaudeUnverified signatureMulti-unit move/attack-move used to just spread the group across a flat square grid (engine/commands.js formationSpots) with no leader concept and no way to hold that shape once stationary. This adds: - Four selectable formation shapes (engine/formation.js): Grid (the original spread, kept byte-identical for the default case), Line (abreast the direction of travel, leader nudged front or back), Wedge (a spearhead with the leader at the tip, or a protective chevron with the leader shielded at the rear and flanks leading), and Circle (a ring around the leader at its center β "protection of a formation," the group-scale sibling of the existing single-target Escort). - A deterministic "leader": the unit with the most maxHp, ties broken by id β never selection-order-dependent. - Spacing derived from the group's own hull sizes, not a flat constant, for every shape except the untouched default grid path. - Nested formations: a selection already spread into distinct spatial β¦4c8f450 -
Land at your last-used Spaceport; pick blind on a fogged minimap otherwiseβ
ClaudeUnverified signatureA jump's landing zone was always a world's fixed, generation-time anchor point (map.bases.player) β the same spot on every visit, with no memory of anything the player built there. Now: - If the destination already has a player Spaceport standing (built on an earlier visit), the fleet lands right at it β whichever pad was most recently used to land there (engine/galaxy.js's new `lastLanding` timestamp on the building, tie-broken by id for a never-used pad). - Otherwise there's no beacon to home in on, so the player picks an approximate landing site themselves on a new "blind minimap" modal (landingPicker.js) before the jump executes β fully fogged (no terrain, fog, nodes or entities drawn), reusing minimap.js's coordinate mapping. The pick is deliberately imprecise: engine/galaxy.js's snapLandingPoint rounds it onto a fixed grid, previewed as a dashed ring around the marker. - A Spaceport-less origin (the existing "control switch" fallback that moves no units) never β¦d1cc6d6
-
Helium Bomb: a detonation also terraforms - the crater matures into oreβ
Claude +1: Claude Sonnet 5Unverified signatureA detonation now schedules a crater (state.craters) at the blast center in addition to erasing everything in range. CRATER_SPAWN_DELAY (60s of sim time) later, engine/sim.js's per-tick updateCraters call turns it into a real ResourceNode - deterministically picked (hashStr off the crater's own id, no engine randomness) from every Raw-tier commodity, not just what this planet's own deposit table naturally rolled. It's a plain node once it exists: gather.js, fog/discovery, and rendering need zero special-casing, since node type is already derived purely from COM[com].extract. The one real complication is persistence. A normal map-generated node is regenerated fresh from the seed on load and only needs its `amount` saved - but a crater node doesn't exist in that regeneration at all. serPlanet now saves a crater node's whole shape (tagged `crater: true`) instead of just {id, amount}, and rehydratePlanet re-adds it to the regenerated map after the fact, sanitized the same way a tampered enβ¦5330c74 -
Add the Helium Bomb: a mobile, arm-then-detonate doomsday unitβ
Claude +1: Claude Sonnet 5Unverified signatureA new Odyssey unit (engine/entities.js UNITS.heliumbomb), built at the Star Dock alongside the Leviathan, costed entirely in the three named materials: gas (Helium-3), antimatter, and plasmatorp (Plasma Torpedoes) - all three already-real commodities, no new economy pieces needed. Lifecycle: built UNARMED (safe to move anywhere, no different from any other unit) - the player ARMS it via a HUD toggle (hudSelection.js, same direct-mutation pattern as the Mender's auto-repair switch) - once armed, it detonates the instant any of three triggers fires: - it's attacked at all (combat.js's performAttack calls engine/bomb.js's detonateIfAttacked before applying normal damage - any hit sets it off instead of chipping its hp) - a live enemy unit or building comes within BOMB_DETECT_RANGE (checked once per tick from sim.js for every role:"bomb" unit) - the player clicks "Detonate Now" (calls detonateBomb directly) All three funnel through the one detonateBomb() function in the β¦53d4247 -
Fix jump only ever using the first of multiple Spaceportsβ
Claude +1: Claude Sonnet 5Unverified signatureplayerSpaceport() picked exactly one completed Spaceport via Array.find() - whichever one Map iteration happened to return first. jumpCapital, jumpVessel, and canJump all routed through it. A second (or third) completed Spaceport's staged units were silently invisible to every jump, forever: not included in the manifest, not counted in leftBehind, just never considered - and a colony ship staged only near that second pad was never reported as loaded either. Added jumpManifestAll(), which combines every completed player Spaceport on the current world into one manifest: each staged unit boards through its nearest pad (deduped so a unit in two overlapping catchment radii can't be double-counted), each pad fills its own capacity closest-first exactly like the existing single-pad jumpManifest (byte-identical output when there's only one pad - verified against the full existing test suite unchanged). jumpCapital now uses it; jumpVessel and canJump now check every pad instead of just the firβ¦f3ed241 -
Persistence: fix docs contradicting the code, document a hazard, add dialog a11yβ
Claude +1: Claude Sonnet 5Unverified signature- CONTRIBUTING.md told contributors to make the loader tolerant of older saves; README.md had two passages that disagreed with each other, one correctly saying an incompatible save is rejected, the other claiming loaders stay "backward-tolerant." The actual code (deserializeGame/deserializeGalaxy) does an exact version-match throw, no migration, no tolerance at all. Rewrote all three passages to describe what the code actually does, and to explain when a version bump is (and isn't) needed. - peekEntityId/restoreEntityId touch a module-global counter in engine/state.js from four call sites in persist.js, with no comment in persist.js itself flagging the shared-mutable-state hazard - the only place this was documented was a test comment elsewhere. Added a clear comment at the import site. - saveload.js's goHome() hand-built confirmation modal (gates real data loss) had no role="dialog", no aria-modal, and no focus management. Added both, plus focus-into-dialog-oβ¦b6109dc -
Galaxy/starmap: pause the sim while it's open, unhide toast alerts, cache index lookupsβ
Claude +1: Claude Sonnet 5Unverified signature- openStarmap/closeStarmap never paused/resumed the sim, unlike every other modal in this codebase - the AI, diplomacy, and economy kept ticking behind an opaque snapshot. Now calls pauseLoop("starmap")/resumeLoop("starmap") on every open/close path (including Escape and backdrop click). Separately, .starmap-overlay's z-index (30) sat above .galaxy-toast-stack's (20), so a "colony under attack/lost" alert rendered invisibly behind the starmap. Bumped the toast stack to 35. - galaxy.js's background-world scheduler ran galaxy.worlds.indexOf(id) every frame for every background world, an O(n) scan on an array that never changes shape after creation. Replaced with a WeakMap-cached id->index Map, keyed on the array's own identity (self-invalidating if a new array is ever assigned). Verified the one place that mutates a worlds array in place (persist.js's roster-backfill loop) does so before the array is ever exposed as a live galaxy.worlds, so the cache can't go stalβ¦003c805 -
AI: fix scout-kidnap bug, dedup a filter, fix Rusher's all-in wave orderβ
Claude +1: Claude Sonnet 5Unverified signature- The scout-replacement fallback picked the first non-scout army unit with no check for whether it was idle or mid-attack - if the old scout died during an active assault, the fallback could pull a unit off the fight to go scouting instead. Now filters to units with no active order (or still walking to rally), the same idiom already used elsewhere in this file to identify "home army" units. - The same 2-line visible-enemy-combat-unit filter was hand-copied into three functions (applyFocusFire, visibleEnemyCombatNear, visibleThreatsNearHome). Extracted into one shared generator. - withoutHomeGuard's "send the forward-most units" logic only sorted by distance from home when garrison > 0; for an all-in archetype with garrison:0 (the Rusher), it returned the army unsorted, so a partial-commit wave silently drew from insertion order instead of genuinely the forward-most units. Now sorts unconditionally; behavior for garrison > 0 is unchanged (verified: identical codeβ¦1ffe9fb -
Economy: cache the per-tick power throttle, fix a false doc comment, dedup a surveyβ
Claude +1: Claude Sonnet 5Unverified signature- powerThrottle is owner-wide, but updateProduction and updatePlasmaRig each called it once per BUILDING - every factory and rig redid the identical draw/cap scan (including the O(B) grid-distance search inside it) from scratch, every tick: an O(B^2) recompute. Added cachedPowerThrottle, which memoizes the result per owner per state.tick (modelled on supply.js's and sim.js's existing "freeze it once per tick" pattern) and self-invalidates the instant the tick advances. Byte-identical output to calling powerThrottle fresh; only callers that go through updateProduction/ updatePlasmaRig are affected. - powerCap/powerDraw dereferenced BUILDINGS[b.type] without the ?. guard a sibling function three lines above already uses - added for consistency. - A doc comment claimed electrify was "player-only in practice"; the Odyssey AI electrifies its own buildings too (engine/aiIndustry.js). Corrected. - rig.js's updatePlasmaRig/rigInfo each called rigVein() and locationRichnesβ¦b22641b -
Sim core: fix stale balance comment, reuse queryNeighbors' scratch bufferβ
Claude +1: Claude Sonnet 5Unverified signature- combat.js's comment claimed Bastion's range was 24; it's 44 (entities.js bumped it, with its own comment admitting so nearby) - just a stale number. - grid.js's queryNeighbors allocated a fresh result array on every call (~3x per unit per tick across movement/separation/combat), in a file whose own header states a no-per-tick-garbage goal. Now reuses one scratch array. Verified every call site (movement.js, repair.js, separation.js, combat.js) reads the result via an immediate, synchronous, non-nested for-of and discards it before the next call - no caller holds a reference past that or triggers a nested queryNeighbors call while iterating, so sharing the buffer is safe. combat/sim/grid/separation/movement/determinism tests all still pass unmodified. - sim.js's tick() now guards against a missing UNITS[unit.type] def - belt and suspenders; persist.js already strips unknown-type entities on load, so this covers only a hypothetical future code path that bypasses iβ¦1702aab -
Harden save/load: sanitize sizeMult/resourceMult and player economyβ
Claude +1: Claude Sonnet 5Unverified signatureTwo load-time gaps in the otherwise-paranoid persist.js: rehydratePlanet passed a save's sizeMult/resourceMult straight into generateMap() with no sanitization (map.js's `opts.sizeMult || 1` only catches falsy values, so a NaN or numeric string sails through and produces a NaN-sized map, which then defeats every coordinate clamp cleanEntity performs elsewhere), and player resources/upgrades round-tripped with no validation at all, unlike every entity buffer. Sanitize sizeMult/resourceMult once (finite, positive, floored at 0.1, defaulting to 1) and reuse the same value for both map generation and the state assignment, so the two can never disagree. Add cleanPlayer(), mirroring coerceBuffer's style, to keep only real commodity/tech/upgrade ids with sane values. Both fixes live in rehydratePlanet, so skirmish and Odyssey saves get them for free. New adversarial tests in save-hardening.test.js cover both gaps plus identity round-trips for valid values; the existing byte-identical round-tβ¦e738400 -
Fix the scout-a-building crash: unexported drawEnemyPip + harden loop.jsβ
Claude +1: Claude Sonnet 5Unverified signaturerenderBuildings.js called drawEnemyPip for every non-player building without importing it β it was a private function in renderUnits.js. The first fog-visible enemy building threw a ReferenceError, and because engine/loop.js had no try/catch around its render() call, the throw killed the requestAnimationFrame chain permanently: sim and render both stopped for the rest of the session. Export drawEnemyPip and import it where it's used. Wrap only the render() call in loop.js's frame() in try/catch (update() stays unguarded β a throwing sim update is a different problem) so one bad draw degrades a frame instead of bricking the game. Add a direct regression test (verified it fails with the exact ReferenceError against the pre-fix code) plus a loop.js test proving a throwing render doesn't stop later frames. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Dmxcvm178TEt2wVXrX5Cj1693efa9 -
Split engine/ai.js god file into cohesive phase modulesβ
Claude +1: Claude Opus 4.8Unverified signatureengine/ai.js was a 1147-line god object holding the whole AI. Decompose it into five cohesive sibling modules along an acyclic import graph, leaving ai.js as a 110-line orchestrator that keeps exporting runAI (so sim.js and the AI tests are unchanged): - aiCommon.js β the APM action budget (accrueActionBudget/canAct/spend), reserve-aware canAffordKeeping, and the pickBuilder worker pick. A leaf with no engine imports, shared by every phase. - aiWorkers.js β idle-worker logistics + gather steering (assignAiLogistics/ assignIdleWorkers) and the map-aware mix filters (effectiveMix, affordableOnSurface, aiDoctrine). - aiMilitary.js β defend/attack waves (aiMilitary/aiOffense), focus-fire, the scout sweep, and the target/mix picks (chooseAttackTarget, raidTarget, pickNextUnitType, counterToPlayerArmy). - aiEconomy.js β base build-out, expansion, the Foundry/Arsenal tech gates, β¦240c1d3 -
Two-owner scaffold: structural generalization (owner-generic, 1v1 byte-identical)β
Claude +1: Claude Opus 4.8Unverified signatureThe `state.players = {player, ai}` scaffold was hardcoded across the engine β two named literals for the player map, two `createFog` calls, two `seedPlayer` calls, two `updateFog` calls, a two-branch victory check, and the save serialize/rehydrate. Combat, movement, separation and the spatial grid were already owner-generic (`owner !== self`); only the scaffold named the two sides by hand, so adding a side meant a sweep across ~15 files. Generalize the scaffold to ITERATE `state.owners` instead of naming the pair: - state.js: an `ownerDefs` list builds `state.owners`, `state.players` and a per-owner `state.fogs` map by loop; `state.fog` / `state.fogAI` become aliases into `state.fogs` so the many existing fog consumers keep working unchanged; seeding and initial fog run as loops over `owners`. - victory.js: `checkWinCondition` reads last-side-standing over `state.owners` (one side left β it wins; none β score); `scoreLeader` picks the highest score with a first-listed tie-bβ¦b2772b8 -
AI logistics: true symmetry β the AI hauls its own industry, no more free treasuryβ
Claude +1: Claude Opus 4.8Unverified signatureResolves the AI-logistics asymmetry from the architecture review. The AI's factories/rigs used to run off an owner==="ai" abstraction β inputs drawn straight from the treasury, outputs banked straight back, no buffers, no workers, no stalls β so the finite-storage/ haulage system (the headline Odyssey reshape) was a labour tax only the human paid, and the two economies weren't comparable. Now the AI runs the SAME finite-buffer + worker-haulage model as the player: - Deleted the abstract branches in industry.js/rig.js. updateProduction/updatePlasmaRig are owner-agnostic again: a factory only produces once workers fill its input larder and keep its output buffer clear (else it stalls), and a rig's finite buffer must be hauled off. - engine/ai.js assignAiLogistics: dedicates a BOUNDED share of idle workers (<= half the pool, so gathering never starves) to service factories / haul the rig, reusing the exact owner-generic machinery the player's workers use (assignService/assignHaulβ¦8cd6f2e -
Address remaining review defects: B3βB6 + load-hardening + static checksβ
Claude +1: Claude Opus 4.8Unverified signatureA fanned-out team of agents fixed the remaining SAFE items from the architecture review, partitioned by file so they never collided; verified and committed centrally. All identity for valid data (guarded on field presence/range), so determinism + round-trip guarantees hold β behavior changes only for corrupt/tampered/NaN input. Load hardening (engine/persist.js, test/save-hardening.test.js): - B3: clamp a wonder's `charge` to [0,1] on load β a hand-edited charge:1 no longer trips an instant standalone-endless win (victory.js). - B4: recompute the galaxy `g`-id counter (`entitySeq`) from live g-ids across all worlds on load, mirroring maxOwnEntityId for the u/b counter β a low/missing entitySeq can no longer mint a colliding g-id over an in-flight colony ship / freighter / relief ship. - B5: coerce untrusted order/orderQueue coords (finite, in-map) and worker cargo (finite qty, real commodity) so a tampered save can't NaN-poison the movement/gather math. - Non-array `researchQuβ¦fdea120 -
Fix B1 + B2 from the architecture reviewβ
Claude +1: Claude Opus 4.8Unverified signatureB1 β faction expansion could flip the AI faction of the world the player is ON. checkExpansion picks the nearest UNCLAIMED world and sets its AI's faction to the expander's; faction feeds live combat/economy multipliers (factions.js β sideMod, read on every hit and haul), and there was no activeId exclusion β so a distant faction "expanding" into the player's current world silently changed the enemy's damage/sight/ speed/gather mid-battle, with only a starmap toast. Now expansion skips the active world and any world the player holds a foothold on; it only reaches the unclaimed, unheld fringe. (engine/galaxy.js checkExpansion.) B2 β a corrupt production queue bricked the game. updateProductionQueue did `UNITS[job.unitType].buildTime` with no guard, so a bogus unitType (localStorage bit-rot or a hand-edited save) threw on the first tick β inside the rAF loop, past load's try/catch β and since it's the autosave, every reload re-crashed. Two-layer fix: β’ runtime guard in updateProductioβ¦785c4de
-
Living galaxy (7/N): factions expand across planets + starmap territoryβ
Claude +1: Claude Opus 4.8Unverified signatureThe payoff of the living galaxy: AI factions now spread between worlds. A new galaxy-level faction-territory model (checkExpansion, on the throttled galaxy scan): - SELF-CLAIM: a world whose AI has developed past CLAIM_DEV flies its own faction's flag. - EXPAND: the single most-developed claimed world (past EXPAND_DEV) colonises the NEAREST still-unclaimed world, claiming it AND flipping that world's AI to its colours β so a thriving faction absorbs the fringe and its territory grows across the starmap over a long game. One cross-planet claim per scan keeps the spread gradual; it's paced by how fast worlds develop (minutes) and converges once every world is claimed. Deterministic: development is an entity count, distance is fixed planet-x, order is the fixed roster, ties break by world id β no clock, no RNG. Reads/writes only galaxy.claims (persisted) and the AI's faction (persisted), so it's save/load-safe. Surfaced for the player: galaxyStatus reports each world's controllβ¦bd7958c -
Living galaxy (6/N): every world simulates from the startβ
Claude +1: Claude Opus 4.8Unverified signaturecreateGalaxy now instantiates ALL worlds (unsettled, background) at galaxy creation, not just the player's start seat β so each world's AI faction founds a base and develops via aiIndustry, its economy growing and diplomacy drifting, before the player ever visits. The galaxy is alive from turn one. A probe puts the whole 11-world galaxy at well under 1 ms/ frame (the BG scheduler already spreads the work; background armies stay bounded), so this is perf-safe. Because every world now exists, "the state object exists" can no longer mean "the player has been here." A new `galaxy.discovered` set tracks worlds the player has actually REACHED: - jumpCost is free to a discovered world (or one you hold a foothold on), distance-scaled to an unreached one β so exploration still costs fuel; - galaxyStatus reads a world "unexplored" (and hides its stance) until it's discovered, and reports discovered.size as "visited" β the starmap looks exactly as before until you travel; - jumpCapital marksβ¦ad2fc1c -
Diplomacy (5/N): development keeps the peaceβ
Claude +1: Claude Opus 4.8Unverified signatureTies the new industrial AI to war/peace, as requested ("develop β¦ that may avoid war"). War onset is scarcity-driven (target = 0.6 β depletionΒ·1.6); now a neighbour investing in its OWN industry β Reactors, factories, a Plasma Rig, a Datacenter, and researched tech nodes β makes its own goods instead of fighting you for the last surface seam, so each such asset lifts its war target (bounded at +0.4). So a self-sufficient developer coexists markedly longer than a bare strip-miner at the same depletion, and can hold off war entirely on a world you don't strip-mine β but development only DELAYS war: past the cap, scarcity and the late-game creep still bite (a fully-mined world tips hostile even at full development), and the charging-Gate finale still overrides regardless. Zero for a bare early neighbour and for the whole skirmish path (no diplomacy), so the stance maths is unchanged until the AI actually develops. - engine/diplomacy.js: aiDevelopment(state) + a bounded softening term onβ¦5caed23 -
AI industry (4/N): the capital path β Star Dock, Leviathans, Plasma Rigβ
Claude +1: Claude Opus 4.8Unverified signatureThe payoff for the deep climb and the sink for the AI's strategic goods. Once the whole Strategic tree stands (a Star Dock's prereqs β AI Foundry + Torpedo Works β are met), the developer AI: - founds a Star Dock and trains LEVIATHANS from it β a real capital ship (role "combat", so the existing wave logic folds it into the AI's attacks), costed in the AI Cores + Plasma Torpedoes its own chain manufactures, gated on supply headroom; - raises a Plasma Rig once it has the AI Foundry (pilot) + a Reactor (grid) and the manufactured machinery/electronics/AI Cores it costs β an unlimited late-game ore source, banked straight to the treasury via the phase-1 abstraction. Emergent, not scripted: only a patient developer on a resource-rich world researches deep enough to reach it. Odyssey-only; skirmish untouched. - engine/ai.js: aiIndustry extended with the Star Dock / Leviathan / Plasma Rig steps. - test/aiIndustry.test.js: with the Strategic tree pre-placed, the AI founds a Star Doβ¦060fae6 -
AI industry (3/N): the AI climbs the factory chain and researches the tech treeβ
Claude +1: Claude Opus 4.8Unverified signatureA patient developer AI (Economist/Balanced β the same signal as the Refinery; a Rusher stays lean) now raises the whole industrial chain and works the Datacenter tech tree: - FACTORY CHAIN: builds the next building whose prereqs are met and it lacks, lowest tier first (Smelter β Datacenter β Assembler β Chip Fab β Machine Works β Antimatter Forge β AI Foundry β Torpedo Works). prereqsMet enforces the ordering, so it can only climb as the research beneath each factory lands. Spread in a spiral around the CC so the power grid stays tight; reserve-aware, one per think cycle. - RESEARCH: at a completed Datacenter it queues the next unowned node lowest-tier-first (Metallurgy, Fusion Containment, Microelectronics, Automation, Heavy Alloys, Precision Machining, Antimatter Containment, Machine Minds) β paid in gathered crystals/radioactives. So a world's deposits gate how deep its AI can climb. Also fixes a Reactor over-build: powerCap counts only completed reactors, so while oβ¦dd7cbe7 -
AI industry (2/N): the AI powers and electrifies its baseβ
Claude +1: Claude Opus 4.8Unverified signatureNew Odyssey-only aiIndustry phase in the AI brain: once it has a base + Barracks it raises a Reactor (scaled to need β another when the grid runs tight) and, once the grid is live, wires its non-power buildings in (electrified). That's 30% faster unit production at the Barracks/CC and +30% supply at Habitats β a universal "develop your base" behaviour that makes every Odyssey neighbour, on every background world, visibly stronger and more alive. Runs after unit production so power is raised from surplus (the army never freezes to build it), APM-budgeted and reserve-aware. Skirmish is a no-op (the endless gate), so the byte-identical short game is untouched. - engine/ai.js: aiIndustry(state, ctx) β Reactor when none/grid tight; electrify one eligible building per think cycle once powered. Imports powerCap/powerDraw and isElectrifiable. - test/aiIndustry.test.js: an Odyssey AI builds a Reactor and electrifies; a skirmish AI builds neither. Co-Authored-By: Claude Opus 4.8 <noreplβ¦a271172 -
AI industry (1/N): abstracted AI logistics β factories & rigs run off the treasuryβ
Claude +1: Claude Opus 4.8Unverified signatureThe finite-storage/haulage economy is player-only: sim.js auto-assigns haul/service work only to player workers, so an AI-built factory never gets inputs carried in or outputs carried off, and an AI rig's output buffer never drains β they'd produce nothing. This blocks the AI from ever using the new Odyssey industry. Enabling change: the player does logistics by hand (finite input/store buffers + worker haulage β a skill differentiator); the AI's logistics are ABSTRACTED. For an owner==="ai" building, updateProduction draws inputs straight from the treasury and banks output straight back, and the Plasma Rig banks its dig straight to the treasury β no haulage, no buffer to fill and stall on. The power throttle still applies, so Reactors stay a real constraint and the grid still matters. Gated on owner==="ai": the player path (buffers + haulage) is byte-for-byte unchanged, and a skirmish never instantiates a factory/rig so its replay is untouched. This is the one core change; later phaβ¦50f1d44 -
Electrify: wire non-power buildings into the grid for +30%β
Claude +1: Claude Opus 4.8Unverified signatureAn Odyssey non-power building β a Command Center, Barracks, Star Dock or Habitat β can now be ELECTRIFIED: wired into the power grid to run 30% better. A producer trains its units 30% faster; a Habitat houses 30% more. The upgrade isn't free. An electrified building adds a steady grid draw (ELECTRIFY_POWER, grid-efficiency scaled like any consumer), so lighting up the whole base competes with the factories for Reactor Power. And the payoff scales with the player-wide power throttle: the full +30% only while the grid can carry the load, tapering as it runs short and 0 with no active source at all β so it's worth it once you have Power to spare, not as a free stack. - isElectrifiable(type) (entities.js): a building not already on the power economy (no recipe/reactor/generator/rig/wonder) that has something to boost (produces || supplyGrants). - ELECTRIFY_POWER draw + electrifyBoost(state, owner) = 0.3 Γ throttle (industry.js); powerDraw counts each electrified building. - Boost aβ¦c2a29e2 -
Auto-repair: one Mender per building β drones spread out instead of dogpilingβ
Claude +1: Claude Opus 4.8Unverified signatureEvery auto-repair Mender independently picked the single most-worn building, so they all converged on the same target. Now a per-tick claim tally caps it at one auto-repair Mender per building: countMenderTargets (sim.js, frozen at tick start like the hauler counts) tallies each building's committed drones, and autoRepairRoam skips a building already claimed and claims the one it takes for the rest of the tick. So with several worn buildings the menders fan out one-to-one; with fewer buildings than menders the extras stay off rather than piling on. Buildings only β a wounded UNIT can still draw several menders. Deterministic, player-only (AI menders don't auto-repair), transient menderClaims stripped from saves. Tests: maintenance.test.js gains "menders spread one-per-building" and "extra mender doesn't pile on the lone worn building". Full suite 607 green, tsc clean. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AEQUVetLk31Jβ¦a485a5f -
Fix auto-repair ping-pong: hysteresis, most-worn priority, slower wearβ
Claude +1: Claude Opus 4.8Unverified signatureThe auto-repair Mender oscillated: it targeted ANY building below max HP, so the instant gentle decay nicked a freshly-healed hull the drone was yanked back β heal, leave, decay, return, forever. - Hysteresis: the Mender is only ATTRACTED to a friendly worn past NEEDS_REPAIR (85%), and once committed it STAYS on that target until it's topped back above HEALED (98.5%) β a hair of decay on a full building no longer re-grabs it, and it can't flip between two similar targets mid-approach (a transient repairTargetId holds the commitment). - Priority: it now goes to the MOST worn friendly first (lowest HP fraction), distance only breaking ties β not merely the nearest. - Slower wear: DECAY_FRAC 0.002 β 0.0006 (~18 min to the floor), so maintenance is a gentle long-game pressure rather than a constant chore, and a parked Mender's passive heal trivially out-paces it (the hull stays full β never re-attracts the drone). Net: a Mender heals the worst-off building, tops it up, then Pβ¦56dcb34 -
Maintenance: Odyssey buildings decay; Menders auto-repair and run on grid powerβ
Claude +1: Claude Opus 4.8Unverified signatureKeeping a base standing becomes real upkeep in Odyssey. - Building decay (sim.js): a completed Odyssey structure sheds a small share of its max HP per second (DECAY_FRAC) down to a 35% floor β neglect weakens it but never razes it; combat still can. Gentle and deterministic; skirmish is untouched (its byte-identical short-game replay is unaffected), so it applies to both sides on a world where a Mender's passive repair easily out-heals it. - Mender power (repair.js + industry.js onPowerGrid): on an Odyssey world a Mender heals at full rate only while it's on the powered grid (near an active Reactor or Combustion Generator) and drops to reserves (30%) off-grid β it recharges from the power stations. A skirmish Mender heals at full rate as before. - Auto-repair mode (sim.js): a per-Mender toggle makes an idle drone ROAM to the nearest damaged friendly building/unit so it actively maintains the base/army instead of sitting still; the passive pass mends it on arrival. Plβ¦b0bc371