From d68ec66cbee063f0fe21ef903a53f730e746a853 Mon Sep 17 00:00:00 2001 From: Scott Anderson <662325+scottanderson@users.noreply.github.com> Date: Mon, 19 May 2025 22:26:34 -0400 Subject: [PATCH] Nations prefer bots over players --- src/core/execution/utils/BotBehavior.ts | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/src/core/execution/utils/BotBehavior.ts b/src/core/execution/utils/BotBehavior.ts index afbb53331..1dc98ece9 100644 --- a/src/core/execution/utils/BotBehavior.ts +++ b/src/core/execution/utils/BotBehavior.ts @@ -89,6 +89,7 @@ export class BotBehavior { } } + // Nation enemy selection selectEnemy(): Player | null { if (this.enemy === null) { // Save up troops until we reach the trigger ratio @@ -97,6 +98,15 @@ export class BotBehavior { if (ratio < this.triggerRatio) return null; } + // Select the most hated player + if (this.enemy === null) { + const mostHated = this.player.allRelationsSorted()[0]; + if (mostHated !== undefined && mostHated.relation === Relation.Hostile) { + this.enemy = mostHated.player; + this.enemyUpdated = this.game.ticks(); + } + } + // Prefer neighboring bots if (this.enemy === null) { const bots = this.player @@ -109,15 +119,6 @@ export class BotBehavior { } } - // Select the most hated player - if (this.enemy === null) { - const mostHated = this.player.allRelationsSorted()[0]; - if (mostHated !== undefined && mostHated.relation === Relation.Hostile) { - this.enemy = mostHated.player; - this.enemyUpdated = this.game.ticks(); - } - } - // Sanity check, don't attack our allies or teammates if (this.enemy && this.player.isFriendly(this.enemy)) { this.enemy = null; @@ -125,6 +126,7 @@ export class BotBehavior { return this.enemy; } + // Bot enemy selection selectRandomEnemy(): Player | TerraNullius | null { if (this.enemy === null) { // Save up troops until we reach the trigger ratio