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:

<DISCORD USERNAME>

Co-authored-by: evan <openfrontio@gmail.com>
This commit is contained in:
evanpelle
2025-05-05 20:08:05 -07:00
committed by GitHub
parent 8479fab49d
commit 8805367db7
+10 -5
View File
@@ -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,