From b0cb066e36356ce9078c6151e88352963757e738 Mon Sep 17 00:00:00 2001 From: 1brucben <1benjbruce@gmail.com> Date: Sat, 26 Apr 2025 17:05:42 +0200 Subject: [PATCH] bots will attack out of control crown --- src/core/execution/FakeHumanExecution.ts | 46 +++++++++++++++++++++++- 1 file changed, 45 insertions(+), 1 deletion(-) diff --git a/src/core/execution/FakeHumanExecution.ts b/src/core/execution/FakeHumanExecution.ts index 2f0015bfe..e529c29d6 100644 --- a/src/core/execution/FakeHumanExecution.ts +++ b/src/core/execution/FakeHumanExecution.ts @@ -51,6 +51,9 @@ export class FakeHumanExecution implements Execution { private lastDefensePostTick: number = -9999; private builtSAMNearSilo = new Set(); + private dogpileTarget: Player | null = null; + private dogpileLastChecked: number = -1; + constructor( gameID: GameID, private playerInfo: PlayerInfo, @@ -114,6 +117,8 @@ export class FakeHumanExecution implements Execution { tick(ticks: number) { if (ticks % this.attackRate != this.attackTick) return; + this.updateDogpile(); + if (this.mg.inSpawnPhase()) { const rl = this.randomLand(); if (rl == null) { @@ -252,7 +257,18 @@ export class FakeHumanExecution implements Execution { this.behavior.forgetOldEnemies(); this.behavior.checkIncomingAttacks(); this.behavior.assistAllies(); - const enemy = this.behavior.selectEnemy(); + let enemy: Player | null = null; + + if ( + this.dogpileTarget != null && + this.dogpileTarget.isAlive() && + !this.player.isOnSameTeam(this.dogpileTarget) + ) { + enemy = this.dogpileTarget; + } else { + enemy = this.behavior.selectEnemy(); + } + if (!enemy) return; this.maybeSendEmoji(enemy); this.maybeSendNuke(enemy); @@ -787,4 +803,32 @@ export class FakeHumanExecution implements Execution { activeDuringSpawnPhase(): boolean { return true; } + + private updateDogpile() { + const CHECK_INTERVAL = 50; // only check every 50 ticks + if (this.mg.ticks() - this.dogpileLastChecked < CHECK_INTERVAL) return; + + this.dogpileLastChecked = this.mg.ticks(); + + const alivePlayers = this.mg + .players() + .filter((p) => p.isAlive() && p.isPlayer()); + if (alivePlayers.length < 2) { + this.dogpileTarget = null; + return; + } + + const sorted = alivePlayers.sort( + (a, b) => b.numTilesOwned() - a.numTilesOwned(), + ); + const top = sorted[0]; + const second = sorted[1]; + + if (top.numTilesOwned() > second.numTilesOwned() * 2) { + this.dogpileTarget = top; + } else if (this.dogpileTarget != null && this.dogpileTarget != top) { + // if top player changes, reset + this.dogpileTarget = null; + } + } }