From eabd532e2f82e215e9ba02c44e917b8617e6c7e2 Mon Sep 17 00:00:00 2001 From: evanpelle Date: Sun, 27 Apr 2025 14:12:13 -0700 Subject: [PATCH] Tile expansion (#606) ## Description: Modify tile expansion logic, creates more consistent expansion. ## Please complete the following: - [x] I have added screenshots for all UI updates - [x] I confirm I have thoroughly tested these changes and take full responsibility for any bugs introduced - [x] 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: evan --------- Co-authored-by: evan --- src/core/execution/AttackExecution.ts | 21 ++++----------------- 1 file changed, 4 insertions(+), 17 deletions(-) diff --git a/src/core/execution/AttackExecution.ts b/src/core/execution/AttackExecution.ts index 5fbec6111..8d62debb5 100644 --- a/src/core/execution/AttackExecution.ts +++ b/src/core/execution/AttackExecution.ts @@ -21,13 +21,6 @@ export class AttackExecution implements Execution { private active: boolean = true; private toConquer: PriorityQueue = new PriorityQueue((a: TileContainer, b: TileContainer) => { - if (a.priority == b.priority) { - if (a.tick == b.tick) { - return 0; - // return this.random.nextInt(-1, 1) - } - return a.tick - b.tick; - } return a.priority - b.priority; }); private random = new PseudoRandom(123); @@ -227,8 +220,6 @@ export class AttackExecution implements Execution { this.target, this.border.size + this.random.nextInt(0, 5), ); - // consolex.log(`num tiles per tick: ${numTilesPerTick}`) - // consolex.log(`num execs: ${this.mg.executions().length}`) while (numTilesPerTick > 0) { if (this.attack.troops() < 1) { @@ -279,13 +270,9 @@ export class AttackExecution implements Execution { continue; } this.border.add(neighbor); - let numOwnedByMe = this.mg + const numOwnedByMe = this.mg .neighbors(neighbor) .filter((t) => this.mg.owner(t) == this._owner).length; - const dist = 0; - if (numOwnedByMe > 2) { - numOwnedByMe = 10; - } let mag = 0; switch (this.mg.terrainType(tile)) { case TerrainType.Plains: @@ -301,8 +288,9 @@ export class AttackExecution implements Execution { this.toConquer.enqueue( new TileContainer( neighbor, - dist / 100 + this.random.nextInt(0, 2) - numOwnedByMe + mag, - this.mg.ticks(), + (this.random.nextInt(0, 7) + 10) * + (1 - numOwnedByMe * 0.5 + mag / 2) + + this.mg.ticks(), ), ); } @@ -355,6 +343,5 @@ class TileContainer { constructor( public readonly tile: TileRef, public readonly priority: number, - public readonly tick: number, ) {} }