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
This commit is contained in:
Scott Anderson
2025-08-17 23:23:47 -04:00
committed by evanpelle
parent b43363e6a5
commit ec4eff2656
+10 -11
View File
@@ -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);