This isn't a problem per se as I have solved it, but it intrigues me.
Basically rand() isn't generating the same sequence of numbers for the same seed. My program is very long and split into over 40 classes so it wouldn't make sense to post everything here, but check this: after 2 days of playing around with different parts of my code I ended up replacing every call to rand() and srand() to custom versions, and now everything works fine. Now I run my program 10 times with the same seed and it always generates identical output, but that is not the case with the stdlib version.
I tried to reproduce this by writing a small program that outputs rand() results to files but it works as expected so I'm guessing either the C/C++ runtime or one of the third-party libraries I'm using is calling rand() behind the scenes at some point. Is that possible or is all this just a coincidence somehow?
I'm using the following software:
- Compiler: MinGW 4.7.2
- Libraries: SDL 2.0.0 along with SDL_Image and the png/zlib libraries it comes with
Thanks in advance if anyone knows.