mirror of
https://github.com/openfrontio/OpenFrontIO.git
synced 2026-07-14 14:44:56 +00:00
make bot spawner seed gameID
This commit is contained in:
@@ -1,14 +1,16 @@
|
||||
import {Cell, Game, PlayerType, Tile, TileEvent} from "../game/Game";
|
||||
import {PseudoRandom} from "../PseudoRandom";
|
||||
import {SpawnIntent} from "../Schemas";
|
||||
import {bfs, dist as dist, manhattanDist} from "../Util";
|
||||
import {GameID, SpawnIntent} from "../Schemas";
|
||||
import {bfs, dist as dist, manhattanDist, simpleHash} from "../Util";
|
||||
|
||||
|
||||
export class BotSpawner {
|
||||
private random = new PseudoRandom(123);
|
||||
private random: PseudoRandom
|
||||
private bots: SpawnIntent[] = [];
|
||||
|
||||
constructor(private gs: Game) { }
|
||||
constructor(private gs: Game, gameID: GameID) {
|
||||
this.random = new PseudoRandom(simpleHash(gameID))
|
||||
}
|
||||
|
||||
spawnBots(numBots: number): SpawnIntent[] {
|
||||
let tries = 0
|
||||
|
||||
@@ -22,7 +22,7 @@ export class Executor {
|
||||
// private random = new PseudoRandom(999)
|
||||
private random: PseudoRandom = null
|
||||
|
||||
constructor(private gs: Game, gameID: GameID) {
|
||||
constructor(private gs: Game, private gameID: GameID) {
|
||||
this.random = new PseudoRandom(simpleHash(gameID))
|
||||
}
|
||||
|
||||
@@ -72,7 +72,7 @@ export class Executor {
|
||||
|
||||
|
||||
spawnBots(numBots: number): Execution[] {
|
||||
return new BotSpawner(this.gs).spawnBots(numBots).map(i => this.createExec(i))
|
||||
return new BotSpawner(this.gs, this.gameID).spawnBots(numBots).map(i => this.createExec(i))
|
||||
}
|
||||
|
||||
fakeHumanExecutions(numFakes: number): Execution[] {
|
||||
|
||||
Reference in New Issue
Block a user