Removing an invocation of `pickRandom` doesn't invalidate another. (Worst case is that in DE the AI might not be serializeable.)
I tried to bisect it but wasn't successful there are always like 10 units idle.
To fix the issue, the map has to somehow expose the restrictions. Those restrictions could then also be read by the random selection algorithm.
At least that's how I think of it.
Oh, so you choose random as placement - I understand now.
I think it would be a hard to delay the random selection to the mapgen script. One would also have to change replay-summary: there it shouldn't be displayed as "random".
The more complete solution is the one stated in the ticket.
I don't know of a remaining issue of persistent map settings. Also the name of a game should be causally unrelated to the placement.
I know #8148 which is related especially this link.
You need to import the functions you are using something like
import { addAnimals, addBerries, addBluffs, addDecoration, addForests, addHills, addLayeredPatches,
addMetal, addStone, addStragglerTrees, createBluffsPassages, markPlayerAvoidanceArea } from
"maps/random/rmgen2/gaia.js";