fixed pacing bug, improved expansion

This commit is contained in:
evanpelle
2024-09-09 20:31:45 -07:00
parent 3b79ab84f5
commit f24a4b894a
14 changed files with 39 additions and 40 deletions
+9 -3
View File
@@ -6,7 +6,12 @@ import {Terrain} from "../TerrainMapLoader";
export class AttackExecution implements Execution {
private active: boolean = true;
private toConquer: PriorityQueue<TileContainer> = new PriorityQueue<TileContainer>((a: TileContainer, b: TileContainer) => a.priority - b.priority);
private toConquer: PriorityQueue<TileContainer> = new PriorityQueue<TileContainer>((a: TileContainer, b: TileContainer) => {
if (a.priority == b.priority) {
return a.tick - b.tick
}
return a.priority - b.priority
});
private random = new PseudoRandom(123)
private _owner: MutablePlayer
@@ -113,7 +118,7 @@ export class AttackExecution implements Execution {
continue
}
this.addNeighbors(tileToConquer)
const {attackerTroopLoss, defenderTroopLoss, tilesPerTickUsed} = this.mg.config().attackLogic(this._owner, this.target, tileToConquer)
const {attackerTroopLoss, defenderTroopLoss, tilesPerTickUsed} = this.mg.config().attackLogic(this.troops, this._owner, this.target, tileToConquer)
numTilesPerTick -= tilesPerTickUsed
this.troops -= attackerTroopLoss
if (this.target.isPlayer()) {
@@ -159,6 +164,7 @@ export class AttackExecution implements Execution {
this.toConquer.enqueue(new TileContainer(
neighbor,
dist / 100 + this.random.nextInt(0, 3) - numOwnedByMe * 2 + mag,
this.mg.ticks()
))
}
}
@@ -195,5 +201,5 @@ export class AttackExecution implements Execution {
class TileContainer {
constructor(public readonly tile: Tile, public readonly priority: number) { }
constructor(public readonly tile: Tile, public readonly priority: number, public readonly tick: number) { }
}
+10 -3
View File
@@ -60,9 +60,16 @@ export class BotExecution implements Execution {
const toAttack = border[this.random.nextInt(0, border.length)]
const owner = toAttack.owner()
if (owner.isPlayer() && (owner.type() == PlayerType.FakeHuman || owner.type() == PlayerType.Human)) {
if (this.random.nextInt(0, 1) == 1) {
return
if (owner.isPlayer()) {
if (owner.type() == PlayerType.FakeHuman) {
if (!this.random.chance(4)) {
return
}
}
if (owner.type() == PlayerType.Human) {
if (this.random.chance(2)) {
return
}
}
}
this.sendAttack(owner)