File tree Expand file tree Collapse file tree
src/core/execution/nation Expand file tree Collapse file tree Original file line number Diff line number Diff 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 */
7777const 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+
7982export 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 ;
You can’t perform that action at this time.
0 commit comments