@@ -563,15 +563,16 @@ export class NationStructureBehavior {
563563 const otherUnits = player . units ( UnitType . DefensePost ) ;
564564 const { borderSpacing, structureSpacing } = this . spacingConstants ( ) ;
565565
566- // Check if we have any non-friendly non-bot neighbors
566+ // Check if we have any non-friendly non-bot neighbors with more troops
567567 const hasHostileNeighbor =
568568 player
569569 . neighbors ( )
570570 . filter (
571571 ( n ) : n is Player =>
572572 n . isPlayer ( ) &&
573573 player . isFriendly ( n ) === false &&
574- n . type ( ) !== PlayerType . Bot ,
574+ n . type ( ) !== PlayerType . Bot &&
575+ n . troops ( ) > player . troops ( ) ,
575576 ) . length > 0 ;
576577
577578 // Don't build defense posts if there is no danger
@@ -593,7 +594,7 @@ export class NationStructureBehavior {
593594 borderSpacing - Math . abs ( borderSpacing - closestBorderDist ) ,
594595 ) ;
595596
596- // Prefer adjacent players who are hostile
597+ // Prefer adjacent players who are hostile and have more troops
597598 const neighbors : Set < Player > = new Set ( ) ;
598599 for ( const neighborTile of game . neighbors ( closest ) ) {
599600 if ( ! game . isLand ( neighborTile ) ) continue ;
@@ -602,6 +603,7 @@ export class NationStructureBehavior {
602603 const neighbor = game . playerBySmallID ( id ) ;
603604 if ( ! neighbor . isPlayer ( ) ) continue ;
604605 if ( neighbor . type ( ) === PlayerType . Bot ) continue ;
606+ if ( neighbor . troops ( ) <= player . troops ( ) ) continue ;
605607 neighbors . add ( neighbor ) ;
606608 }
607609 for ( const neighbor of neighbors ) {
0 commit comments