Skip to content

Commit 07119b7

Browse files
committed
Density cap on defense posts
1 parent 082c480 commit 07119b7

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

src/core/execution/nation/NationStructureBehavior.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,9 @@ const MAX_MISSILE_SILOS = 3;
7676
/** If we have more than this many structures per 1000 tiles, prefer upgrading over building */
7777
const UPGRADE_DENSITY_THRESHOLD = 1 / 1500;
7878

79+
/** Maximum density of defense posts (per tile owned) before no more can be built */
80+
const DEFENSE_POST_DENSITY_THRESHOLD = 1 / 5000;
81+
7982
export class NationStructureBehavior {
8083
constructor(
8184
private random: PseudoRandom,
@@ -155,6 +158,17 @@ export class NationStructureBehavior {
155158
return false;
156159
}
157160

161+
// Density cap on defense posts
162+
if (type === UnitType.DefensePost) {
163+
const tilesOwned = this.player.numTilesOwned();
164+
if (
165+
tilesOwned > 0 &&
166+
owned / tilesOwned >= DEFENSE_POST_DENSITY_THRESHOLD
167+
) {
168+
return false;
169+
}
170+
}
171+
158172
const targetCount = Math.floor(cityCount * ratio);
159173

160174
return owned < targetCount;

0 commit comments

Comments
 (0)