mirror of
https://github.com/openfrontio/OpenFrontIO.git
synced 2026-06-30 23:13:28 +00:00
use tiles to improve perf
This commit is contained in:
@@ -5,7 +5,7 @@ import {manhattanDist} from "../Util";
|
||||
|
||||
export class AttackExecution implements Execution {
|
||||
private active: boolean = true;
|
||||
private toConquer: PriorityQueue<TileContainer> = new PriorityQueue<TileContainer>(11, (a: TileContainer, b: TileContainer) => a.priority - b.priority);
|
||||
private toConquer: PriorityQueue<TileContainer> = new PriorityQueue<TileContainer>(1000, (a: TileContainer, b: TileContainer) => a.priority - b.priority);
|
||||
private random = new PseudoRandom(123)
|
||||
|
||||
private _owner: MutablePlayer
|
||||
@@ -50,7 +50,7 @@ export class AttackExecution implements Execution {
|
||||
return
|
||||
}
|
||||
|
||||
if (this.toConquer.size() < 10) {
|
||||
if (this.toConquer.size() < 5) {
|
||||
this.calculateToConquer()
|
||||
}
|
||||
if (this.toConquer.size() == 0) {
|
||||
@@ -130,7 +130,7 @@ export class AttackExecution implements Execution {
|
||||
// .filter(t => t.terrain() == TerrainTypes.Land)
|
||||
// .filter(t => t.owner() == this._owner)
|
||||
// .length
|
||||
this.toConquer.add(new TileContainer(neighbor, + this.random.nextInt(0, 4)))
|
||||
this.toConquer.add(new TileContainer(neighbor, 1))
|
||||
}
|
||||
}
|
||||
// }
|
||||
|
||||
@@ -50,7 +50,7 @@ export class BoatAttackExecution implements Execution {
|
||||
this.path = this.computePath(this.src, this.dst)
|
||||
if (this.path != null) {
|
||||
console.log(`got path ${this.path.map(t => t.cell().toString())}`)
|
||||
this.boat = this.attacker.addBoat(1000, this.src.cell(), this.target)
|
||||
this.boat = this.attacker.addBoat(1000, this.src, this.target)
|
||||
} else {
|
||||
console.log('got null path')
|
||||
this.active = false
|
||||
@@ -80,7 +80,7 @@ export class BoatAttackExecution implements Execution {
|
||||
}
|
||||
|
||||
const nextTile = this.path[this.currTileIndex]
|
||||
this.boat.move(nextTile.cell())
|
||||
this.boat.move(nextTile)
|
||||
}
|
||||
|
||||
owner(): MutablePlayer {
|
||||
|
||||
@@ -12,7 +12,7 @@ export class BotExecution implements Execution {
|
||||
constructor(private bot: MutablePlayer) {
|
||||
|
||||
this.random = new PseudoRandom(bot.id())
|
||||
this.attackRate = this.random.nextInt(50, 200)
|
||||
this.attackRate = this.random.nextInt(10, 50)
|
||||
}
|
||||
|
||||
init(gs: MutableGame, ticks: number) {
|
||||
@@ -35,7 +35,7 @@ export class BotExecution implements Execution {
|
||||
const toAttack = ns[this.random.nextInt(0, ns.length)]
|
||||
|
||||
this.gs.addExecution(new AttackExecution(
|
||||
this.bot.troops() / 5,
|
||||
this.bot.troops() / 100,
|
||||
this.bot.id(),
|
||||
toAttack.isPlayer() ? toAttack.id() : null,
|
||||
null
|
||||
|
||||
Reference in New Issue
Block a user