Early-level build discount (B4) and start stock 1000 (B5)

Playtest on the live world: first hour feels a bit slow. B4: levels 1-3 of any building take x0.5/x0.67/x0.83 of the time (FORMULAS.earlyLevels/earlyTimeFactor, off at earlyLevels 0). Builds at 1 h (4 sittings/day) 8.9 -> 11.4, at 24 h 16.5 -> 20.4; mid game moves ~1 day head start (default mix), more for 2 sittings/day. B5: start stock 750 -> 1000 (measured separately: mid game unchanged, 60-min first sitting 12.1 -> 15.4 builds at 1 h). Numbers in docs/BALANCE.md.

Tested: npm test 208/208, openapi check, npm run e2e 61/61 (before B5), 50x30-day bot run INVARIANTS OK after B5. NOT tested: humans (bots only, 2 seeds), B4+B5 combined beyond one run, e2e does not exercise the discount (runs at 4000x speed). Not claimed: balanced.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Q2MJaQ5LXAHzGnTDgceT14
This commit is contained in:
jvanvik 2026-10-11 22:38:37 +02:00
parent cc0524de5e
commit bf7af0679c
10 changed files with 194 additions and 12 deletions

View file

@ -21,6 +21,8 @@
productionGrowth: 1.25,
costGrowth: 1.28,
timeGrowth: 1.16,
earlyLevels: 3, // early-level build discount (docs/BALANCE.md B4): levels 1..earlyLevels are quicker; 0 = off
earlyTimeFactor: 0.5, // build time of level 1 = this x the formula time, rising evenly to x1 at level earlyLevels + 1 (was 1, i.e. none)
storageBase: 1000, // Rack hall level 1
storageGrowth: 1.22,
batteryBase: 200, // Battery bank level 1, in power points
@ -74,7 +76,7 @@
const START = {
fieldLevel: 1,
infra: { core_router: 1, rack_hall: 1, battery_bank: 1 },
resources: { fiber: 750, hardware: 750, capital: 750 },
resources: { fiber: 1000, hardware: 1000, capital: 1000 },
battery: 100,
loyalty: 100,
// Wild slots: the two wild fields get these types unless the signup picks (stage 1: fixed, stage 4 lets you choose)

View file

@ -197,10 +197,19 @@
function coreLevel(town) { const c = town.buildings.core_router; return c ? c.level : 0; }
// Build time in ms to reach `level`. Core router shortens it; world speed divides it.
// Early-level discount on build time (data: F.earlyLevels, F.earlyTimeFactor; docs/BALANCE.md B4). Building up to level L takes
// earlyTimeFactor x the normal time for L = 1, rising evenly to the full time at level earlyLevels + 1; from there on nothing changes.
// earlyLevels 0 (or a factor of 1) switches it off.
function earlyTimeFactor(level) {
const n = F.earlyLevels || 0, f = F.earlyTimeFactor == null ? 1 : F.earlyTimeFactor;
if (!(n > 0) || level > n) return 1;
return f + (1 - f) * (level - 1) / n;
}
// Build time in ms to reach `level`. Core router shortens it; world speed divides it; the first levels get the early discount.
function buildTimeMs(type, level, core, speed) {
const def = buildingDef(type);
const secs = def.time * Math.pow(F.timeGrowth, level - 1) / (1 + F.coreSpeedPerLevel * core) / (speed || 1);
const secs = def.time * Math.pow(F.timeGrowth, level - 1) * earlyTimeFactor(level) / (1 + F.coreSpeedPerLevel * core) / (speed || 1);
return Math.max(F.minBuildMs, Math.round(secs * 1000));
}
@ -778,7 +787,7 @@
unitDef, unitCount, costValue, unitValue, researchKey, researchLevel, researchMult, unitStat, unitCost, trainTimeMs, unitMissing, trainPlan, researchCost, researchTimeMs, researchSpeedBonus, researchPlan, slowestSpeed, movementMs, transportMs, checkUnitsForType, isProtected, firewallMult, effectiveFirewall, attackPower, defencePower, applyLoss, resolveBattle, battlePoints, cacheFraction, lootSplit, carryOf, siegeLevels, loyaltyDrop, takeoverBlock, footprintGate, settleCheck, cleanWild, newTownBuildings, scanStrength, resolveScan, incumbentDefence, decommissionMs, decommissionPlan, transportLinks, transportPlan, rng, hash, distance, tileAt, ruralNear, ruralBonus, pickSpawn,
terrainAt, backboneSites, backboneSiteAt, isBackboneSite, worldAgeDays, worldPhase, tradeReach, tradeRatioOk, tradeTermsCheck, tradeInRange,
backboneDefence, backboneCost, backboneTimeMs, backbonePlan,
buildingDef, isFieldKey, fieldLayout, buildingCost, coreLevel, buildTimeMs, queueSlots, storageCap, batteryCap,
buildingDef, isFieldKey, fieldLayout, buildingCost, coreLevel, buildTimeMs, earlyTimeFactor, queueSlots, storageCap, batteryCap,
fieldOutputPerHour, ratesPerHour, resourcesAt, batteryEmptyAt, unitsOnline, footprintPerDay, footprintAt,
allianceCap, allianceCan, roleRank, outranks, diplomacyMove, pactCancelMs,
footprintNeeded, loyaltyAt, buildPlan, initialBuildings, latencyMs,