make bot spawner seed gameID

This commit is contained in:
evanpelle
2024-09-21 19:41:21 -07:00
parent a1e4584dde
commit c87d0ef3b8
3 changed files with 10 additions and 8 deletions
+2 -2
View File
@@ -19,12 +19,12 @@ export const devConfig = new class extends DefaultConfig {
}
numBots(): number {
return 400
return 1
}
numFakeHumans(gameID: GameID): number {
return 10
return 0
}
// startTroops(playerInfo: PlayerInfo): number {
+6 -4
View File
@@ -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
+2 -2
View File
@@ -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[] {