From ec4eff26567226d971ab2dc4ab2bc8d422812c07 Mon Sep 17 00:00:00 2001 From: Scott Anderson <662325+scottanderson@users.noreply.github.com> Date: Sun, 17 Aug 2025 23:23:47 -0400 Subject: [PATCH] Remove hard structure limit for nations (#1853) ## Description: Remove the structure building limit for AI players, in favor of a simple cost heuristic. Fixes #1561 ## Please complete the following: - [x] I have added screenshots for all UI updates - [x] I process any text displayed to the user through translateText() and I've added it to the en.json file - [x] I have added relevant tests to the test directory - [x] I confirm I have thoroughly tested these changes and take full responsibility for any bugs introduced --- src/core/execution/FakeHumanExecution.ts | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/src/core/execution/FakeHumanExecution.ts b/src/core/execution/FakeHumanExecution.ts index 94bbfa5d9..9be8cbf35 100644 --- a/src/core/execution/FakeHumanExecution.ts +++ b/src/core/execution/FakeHumanExecution.ts @@ -419,23 +419,22 @@ export class FakeHumanExecution implements Execution { } private handleUnits() { - const player = this.player; - if (player === null) return; return ( - this.maybeSpawnStructure(UnitType.Port, 1) || - this.maybeSpawnStructure(UnitType.City, 2) || + this.maybeSpawnStructure(UnitType.City) || + this.maybeSpawnStructure(UnitType.Port) || this.maybeSpawnWarship() || - this.maybeSpawnStructure(UnitType.Factory, 1) || - this.maybeSpawnStructure(UnitType.MissileSilo, 1) + this.maybeSpawnStructure(UnitType.Factory) || + this.maybeSpawnStructure(UnitType.MissileSilo) ); } - private maybeSpawnStructure(type: UnitType, maxNum: number): boolean { + private maybeSpawnStructure(type: UnitType): boolean { if (this.player === null) throw new Error("not initialized"); - if (this.player.unitsOwned(type) >= maxNum) { - return false; - } - if (this.player.gold() < this.cost(type)) { + const owned = this.player.unitsOwned(type); + const perceivedCostMultiplier = Math.min(owned + 1, 5); + const realCost = this.cost(type); + const perceivedCost = realCost * BigInt(perceivedCostMultiplier); + if (this.player.gold() < perceivedCost) { return false; } const tile = this.structureSpawnTile(type);