I’m working on a game simulation. It uses a fixed set of input files to initialize all game state with. To generate random choices I have a single MersenneTwister
instance that I allocate at startup, the seed passed to it is specified on the command-line. All calls to rand
and shuffle!
pass this RNG instance as first argument. So I assume I have all uses of random numbers tied to the seed value provided in order to be able to reproduce and debug failed runs, like in case of a crash or incorrect result.
But I’m trying to figure out whether I’m doing something dumb, or if there is something else going on. The issue I’m facing is that subsequent runs of my program with the same set of input files and same seed value produce the same set of results (as expected), but when I add a println()
or @info
call for debugging a failed run I suddenly get a different set of results. In the log files I can see that apparently the iteration order of certain dict values has changed (which then leads to a different random choice, different actions being played, etc).
So a first question if is guaranteed in Julia that dict iteration with says keys()
and values()
will produce the same order between invocations of julia
if the underlying dict contains the same values? Of course I assume an unchanged Julia version, same optimization level, etc.
Second question is if calls to print stuff could influence things like dict iteration order? I don’t see how, as I assume the dict code is fully self-contained and does not interact with such calls.
Any other ideas what could be going on? As I mentioned in the beginnen, I might just still be doing something dumb somewhere, but I don’t see it.
Edit: first version was accidentally posted before I was done writing
5 posts - 3 participants