mirror of
https://github.com/openfrontio/OpenFrontIO.git
synced 2026-07-17 00:40:13 +00:00
fixed pacing bug, improved expansion
This commit is contained in:
@@ -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) { }
|
||||
}
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user