diff --git a/src/core/execution/BotExecution.ts b/src/core/execution/BotExecution.ts index 3b0354810..84d46768c 100644 --- a/src/core/execution/BotExecution.ts +++ b/src/core/execution/BotExecution.ts @@ -79,7 +79,6 @@ export class BotExecution implements Execution { } this.behavior.forgetOldEnemies(); - this.behavior.checkIncomingAttacks(); const enemy = this.behavior.selectRandomEnemy(); if (!enemy) return; if (!this.bot.sharesBorderWith(enemy)) return; diff --git a/src/core/execution/FakeHumanExecution.ts b/src/core/execution/FakeHumanExecution.ts index af71e77c2..4fa3ec7cd 100644 --- a/src/core/execution/FakeHumanExecution.ts +++ b/src/core/execution/FakeHumanExecution.ts @@ -262,7 +262,6 @@ export class FakeHumanExecution implements Execution { throw new Error("not initialized"); } this.behavior.forgetOldEnemies(); - this.behavior.checkIncomingAttacks(); this.behavior.assistAllies(); const enemy = this.behavior.selectEnemy(); if (!enemy) return; diff --git a/src/core/execution/utils/BotBehavior.ts b/src/core/execution/utils/BotBehavior.ts index afbb53331..e68a0c775 100644 --- a/src/core/execution/utils/BotBehavior.ts +++ b/src/core/execution/utils/BotBehavior.ts @@ -52,7 +52,7 @@ export class BotBehavior { } } - checkIncomingAttacks() { + private checkIncomingAttacks() { // Switch enemies if we're under attack const incomingAttacks = this.player.incomingAttacks(); if (incomingAttacks.length > 0) { @@ -109,6 +109,11 @@ export class BotBehavior { } } + // Retaliate against incoming attacks + if (this.enemy === null) { + this.checkIncomingAttacks(); + } + // Select the most hated player if (this.enemy === null) { const mostHated = this.player.allRelationsSorted()[0]; @@ -145,8 +150,15 @@ export class BotBehavior { this.enemy = neighbor; this.enemyUpdated = this.game.ticks(); } + } - // Select a traitor as an enemy + // Retaliate against incoming attacks + if (this.enemy === null) { + this.checkIncomingAttacks(); + } + + // Select a traitor as an enemy + if (this.enemy === null) { const traitors = this.player .neighbors() .filter((n) => n.isPlayer() && n.isTraitor()) as Player[];