mirror of
https://github.com/openfrontio/OpenFrontIO.git
synced 2026-06-21 17:00:16 +00:00
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:
committed by
evanpelle
parent
b43363e6a5
commit
ec4eff2656
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user