From cf3e3a7a744b0de4ac282d817a1b6896d90ca7db Mon Sep 17 00:00:00 2001 From: FloPinguin <25036848+FloPinguin@users.noreply.github.com> Date: Thu, 5 Mar 2026 01:54:29 +0100 Subject: [PATCH] =?UTF-8?q?Fix=20bot/nation=20player=20ID=20collisions=20c?= =?UTF-8?q?ausing=20missing=20players=20=F0=9F=94=A7=20(#3354)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## 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 --- src/core/execution/BotSpawner.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/core/execution/BotSpawner.ts b/src/core/execution/BotSpawner.ts index c09d0fa6e..3ccea6a35 100644 --- a/src/core/execution/BotSpawner.ts +++ b/src/core/execution/BotSpawner.ts @@ -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[] {