From 8805367db712515e8f725f28270d1dd4498af2b2 Mon Sep 17 00:00:00 2001 From: evanpelle Date: Mon, 5 May 2025 20:08:05 -0700 Subject: [PATCH] have bots attack sooner at start of game (#660) ## Description: For the first attack, just send 1/5 troops and don't wait until the bot has sufficient reserves. It looked weird because none of the bots moved at all for the first 5 seconds of the game. ## Please complete the following: - [ ] I have added screenshots for all UI updates - [ ] I confirm I have thoroughly tested these changes and take full responsibility for any bugs introduced - [ ] I understand that submitting code with bugs that could have been caught through manual testing blocks releases and new features for all contributors ## Please put your Discord username so you can be contacted if a bug or regression is found: Co-authored-by: evan --- src/core/execution/utils/BotBehavior.ts | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/core/execution/utils/BotBehavior.ts b/src/core/execution/utils/BotBehavior.ts index 4f1d5fde9..c4f765c79 100644 --- a/src/core/execution/utils/BotBehavior.ts +++ b/src/core/execution/utils/BotBehavior.ts @@ -16,7 +16,9 @@ export class BotBehavior { private enemy: Player | null = null; private enemyUpdated: Tick; - private assistAcceptEmoji: number; + private assistAcceptEmoji = flattenedEmojiTable.indexOf("👍"); + + private firstAttackSent = false; constructor( private random: PseudoRandom, @@ -24,9 +26,7 @@ export class BotBehavior { private player: Player, private triggerRatio: number, private reserveRatio: number, - ) { - this.assistAcceptEmoji = flattenedEmojiTable.indexOf("👍"); - } + ) {} handleAllianceRequests() { for (const req of this.player.incomingAllianceRequests()) { @@ -172,8 +172,13 @@ export class BotBehavior { const maxPop = this.game.config().maxPopulation(this.player); const maxTroops = maxPop * this.player.targetTroopRatio(); const targetTroops = maxTroops * this.reserveRatio; - const troops = this.player.troops() - targetTroops; + // Don't wait until it has sufficient reserves to send the first attack + // to prevent the bot from waiting too long at the start of the game. + const troops = this.firstAttackSent + ? this.player.troops() - targetTroops + : this.player.troops() / 5; if (troops < 1) return; + this.firstAttackSent = true; this.game.addExecution( new AttackExecution( troops,