diff --git a/src/core/GameImpl.ts b/src/core/GameImpl.ts index 65b04de69..363690899 100644 --- a/src/core/GameImpl.ts +++ b/src/core/GameImpl.ts @@ -123,16 +123,16 @@ export class PlayerImpl implements MutablePlayer { } addTroops(troops: number): void { - this._troops += troops + this._troops += Math.floor(troops) } removeTroops(troops: number): void { - this._troops -= troops + this._troops -= Math.floor(troops) this._troops = Math.max(this._troops, 0) } isPlayer(): this is MutablePlayer {return true as const} ownsTile(cell: Cell): boolean {return this.tiles.has(cell.toString())} - setTroops(troops: number) {this._troops = troops} + setTroops(troops: number) {this._troops = Math.floor(troops)} conquer(tile: Tile) {this.gs.conquer(this, tile)} info(): PlayerInfo {return this.playerInfo} id(): PlayerID {return this._id} @@ -142,6 +142,9 @@ export class PlayerImpl implements MutablePlayer { executions(): Execution[] { return this.gs.executions().filter(exec => exec.owner().id() == this.id()) } + hash(): number { + return this.id() * (this.troops() + this.numTilesOwned()) + } } class TerraNulliusImpl implements TerraNullius { @@ -191,7 +194,6 @@ export class GameImpl implements MutableGame { private _height: number _terraNullius: TerraNulliusImpl - constructor(terrainMap: TerrainMap, private eventBus: EventBus) { this._terraNullius = new TerraNulliusImpl(this) this._width = terrainMap.width(); @@ -215,6 +217,13 @@ export class GameImpl implements MutableGame { this.execs.push(...this.unInitExecs) this.unInitExecs = [] this.ticks++ + if (this.ticks % 10) { + let hash = 1; + this._players.forEach(p => { + hash += p.hash() + }) + console.log(`tick ${this.ticks}: hash ${hash}`) + } } terraNullius(): TerraNullius { diff --git a/src/core/execution/BotExecution.ts b/src/core/execution/BotExecution.ts index 583f9b6e0..f3aa26691 100644 --- a/src/core/execution/BotExecution.ts +++ b/src/core/execution/BotExecution.ts @@ -35,7 +35,6 @@ export class BotExecution implements Execution { return } - if (ticks % this.attackRate == 0) { if (this.neighborsTerra) { for (const b of this.bot.borderTiles()) { @@ -55,7 +54,6 @@ export class BotExecution implements Execution { } const toAttack = ns[this.random.nextInt(0, ns.length)] this.sendAttack(toAttack) - } }