Rand / SeedRnd between B+ / B3D

Archives Forums/BlitzPlus Programming/Rand / SeedRnd between B+ / B3D

morduun(Posted 2003) [#1]
I seem to recall there being an intrinsic change between the way B+ does random number sequences and B3D, to such an extent that given seed X, Blitz3D and Blitz+ will not generate the same sequence of random numbers. Simple experimentation bears this out.

I also seem to recall that someone (Mark perhaps?) posted a way to SeedRnd in such a way that you could get them to work together again.

Assuming I'm not getting my threads mixed up (which I probably am), does anyone remember what needed to happen to the value one passes SeedRnd, and in which environment, to get the two sequences to match up?

Mark Tiffany(Posted 2003) [#2]
I remember it too, but can't spot it. Remind me to update the online docs when we do though...

Floyd(Posted 2003) [#3]
If you want random numbers to match between versions then you should write your own generator.

Mark Tiffany(Posted 2003) [#4]
There *is* a way to make B+ random numbers consistent with those generated from Blitz2d / 3d. I think you have to mask out the first 8 bits or something - i.e. SeedRnd $FFFF & MilliSecs(). Or something.

However, to guarantee the same random numbers across all PCs, you *do* have to roll your own generator - the random number generator will generate different results on different PCs, regardless of whether you apply the above tweak (should we ever find it again...).