diff --git a/src/core/execution/BotExecution.ts b/src/core/execution/BotExecution.ts index f7321ef93..b6fd7399f 100644 --- a/src/core/execution/BotExecution.ts +++ b/src/core/execution/BotExecution.ts @@ -13,12 +13,14 @@ export class BotExecution implements Execution { private active = true; private random: PseudoRandom; private attackRate: number; + private attackTick: number; private mg: Game; private neighborsTerraNullius = true; constructor(private bot: Player) { this.random = new PseudoRandom(simpleHash(bot.id())); this.attackRate = this.random.nextInt(10, 50); + this.attackTick = this.random.nextInt(0, this.attackRate - 1); } activeDuringSpawnPhase(): boolean { return false; @@ -36,9 +38,7 @@ export class BotExecution implements Execution { return; } - if (ticks % this.attackRate != 0) { - return; - } + if (ticks % this.attackRate != this.attackTick) return; this.bot.incomingAllianceRequests().forEach((ar) => { if (ar.requestor().isTraitor()) { diff --git a/src/core/execution/FakeHumanExecution.ts b/src/core/execution/FakeHumanExecution.ts index 59320edeb..43e3e997e 100644 --- a/src/core/execution/FakeHumanExecution.ts +++ b/src/core/execution/FakeHumanExecution.ts @@ -44,6 +44,9 @@ export class FakeHumanExecution implements Execution { private lastNukeSent: [Tick, TileRef][] = []; private embargoMalusApplied = new Set(); + private attackRate: number; + private attackTick: number; + constructor( gameID: GameID, private playerInfo: PlayerInfo, @@ -51,6 +54,8 @@ export class FakeHumanExecution implements Execution { this.random = new PseudoRandom( simpleHash(playerInfo.id) + simpleHash(gameID), ); + this.attackRate = this.random.nextInt(40, 80); + this.attackTick = this.random.nextInt(0, this.attackRate - 1); } init(mg: Game, ticks: number) { @@ -128,9 +133,7 @@ export class FakeHumanExecution implements Execution { return; } - if (ticks % this.random.nextInt(40, 80) != 0) { - return; - } + if (ticks % this.attackRate != this.attackTick) return; if ( this.player.troops() > 100_000 &&