Fix bot/nation player ID collisions causing missing players 🔧 (#3354)

## Description:

BotSpawner used the same PRNG seed (simpleHash(gameID)) as
createGameRunner, causing bot IDs to collide with nation IDs. When a
bot's SpawnExecution found a nation with the same ID via hasPlayer(), it
silently reused that nation instead of creating a new player - resulting
in far fewer players than configured (e.g. ~670 instead of 800 with 400
bots + 400 nations) with no console warnings.

Offsets the BotSpawner seed by +2 to avoid the shared PRNG sequence
(matching the +1 pattern already used by Executor).

## Please complete the following:

- [X] I have added screenshots for all UI updates
- [X] I process any text displayed to the user through translateText()
and I've added it to the en.json file
- [X] I have added relevant tests to the test directory
- [X] I confirm I have thoroughly tested these changes and take full
responsibility for any bugs introduced

## Please put your Discord username so you can be contacted if a bug or
regression is found:

FloPinguin
This commit is contained in:
FloPinguin
2026-03-05 01:54:29 +01:00
committed by GitHub
parent e137fcaa6c
commit cf3e3a7a74
+3 -1
View File
@@ -13,7 +13,9 @@ export class BotSpawner {
private gs: Game,
private gameID: GameID,
) {
this.random = new PseudoRandom(simpleHash(gameID));
// Use a different seed than createGameRunner (which uses simpleHash(gameID))
// to avoid bot IDs colliding with nation/human IDs from the same PRNG sequence.
this.random = new PseudoRandom(simpleHash(gameID) + 2);
}
spawnBots(numBots: number): SpawnExecution[] {