SeedRnd/Random sequences

Miscellaneous Forums/General Discussion/SeedRnd/Random sequences

Hello.

I remember there was some contention over this issue in other versions of Blitz. Does Blitzmax have the same problem?

If I set the same seed on any PC, will I get the same series of random Ints (using Rand()) on every PC? Or does it vary?

Download, extract and run this. (25k, you do not need Blitzmax to test this!)

It'll create a file called 'results.txt' in the same location as the EXE.

My results are as follows:
9
1
96
85
58
84
59
31
3
95


(mods - reposted here so more people can test!)

Nothing happens when you run that. But pretty sure you'll find people will get the same results. That's why you always seed your rnd with for instance milisecs().

same here
9
1
96
85
58
84
59
31
3
95


Nothing happens when you run that.
You'll need to extract it from the ZIP file, otherwise it can't write the output file.

Unless you're running vista, then it might not work. Dunno tho.

Hi GfK - I don't know if blitzmax has the same problem as the other blitzes but since I rely on random numbers for the same seed being consistent across machines I used my own random number algorithm which is the same as that used by VBA - good enough for games but not 'serious statistical simulations'. If you want to see how it works then here is the a useful site:

http://www.noesis.net.au/prng.php

Hmm... that might do the trick for what I need.

Still like to get more feedback regarding the original question though...

9
1
96
85
58
84
59
31
3
95

9
1
96
85
58
84
59
31
3
95

Sweet here.

9
1
96
85
58
84
59
31
3
95

Strange, mine just shot out prime numbers until it reached the last known integer, at which point it disapproved the existence of God.

9
1
96
85
58
84
59
31
3
95

Isn't that supposed to happen though?

Standard encryption works using a known seed.

This has been discussed before (when Win32 Bmax was still in beta, I think?) and Mark stated that as the random number generator is FP based, it couldn't be guaranteed to give consistent results across different CPU/FPU combinations.

I'm also pretty sure that someone made a Mersenne(?) Twister routine/module for BMax. Which, as it's integer based, should give consistant results.

It was a long time ago and although details are a bit fuzzy, I'm fairly sure that the answer to your question is...Yes, BMax does have (or could potentially have, at least) the same problem.

Yes its supposed to. But somebody said ages ago that other versions of Blitz gave different results depending on the PC it was running on.

Personally, the only difference I found was that BlitzBasic and BlitzPlus gave different results to each other using the same seed.

Wasnt it said last time that we had this disscusion that although most people will give the same results, it wasnt garenteed? Sort of like the "Not Clearing" the backbuffer problem.

It depends on what you are doing I suppose, but I am nearly as sure as Mr sure from syreville can be that Yan is right and that over most configerations you will get the same results, but not garenteed.

However your exe is MASSIVE, so I suspect that you are doing more than RND.
9
1
96
85
58
84
59
31
3
95


PS If you have just gotten me to run some Spyware on my computer, Im going to come round and steal your washing.

It uses the same math which is written in BlitzMax language so there's no reason why you'd get a different sequence. You're not calling o/s specific routines.

Here we go again... ;o)

However your exe is MASSIVE, so I suspect that you are doing more than RND.
60k is massive??

I'm writing to a file, which requires brl.filesystem.

It uses the same math which is written in BlitzMax language so there's no reason why you'd get a different sequence. You're not calling o/s specific routines.
Looking at the code, it uses RndDouble() even for calculation of Ints.

It was the floating point element of the calculation that was alleged to have caused discrepancies before.

9
1
96
85
58
84
59
31
3
95

Whew.

I'm fairly sure it was Kanati who made the Mersenne Twist routine... it was available for download along with the printer dll and BlitzData stuff.

last thread here... http://www.blitzbasic.com/Community/posts.php?topic=63234#706298

However your exe is MASSIVE, so I suspect that you are doing more than RND.

60k is massive??
Well I had started to write the post before I downloaded or ran the program, so I didnt realise it was outputting to a file ;) (ANd I dint really read your post, so thought it was code)

I left it in cos I thought it the spyware comment was funny

I left it in cos I thought it the spyware comment was funny
How many times can one person be wrong in a single day, huh? ;)

Depends on how many posts I make.

9
1
96
85
58
84
59
31
3
95


9
1
96
85
58.7
84
59
31
3
95


I'd wager your sample probably isn't large enough to show any real disparity. In the old days DirectX and OpenGL would give different results (eventually) after a longer period of time.

If you can find a BlitzMAX implementation of the Mersenne Twister algorithm, that's definately the one you should use.

How come Goose got a .7?

I remember there was some contention over this issue in other versions of Blitz
There was no problem in other versions of Blitz. One of my Blitz3D games relied soley on the results SeedRnd generating the same sequances on all pc's. The game was tested on several thousand pc's from all over the world and not one of them threw up an eronious result, ever. I don't know how that rumour started, but I challanged several forum members on the issue and not one of them could produce an incorrectly working example of SeedRnd in Blitz3D. I believe John Pickford will be able to confirm this. I remember him saying he seeds the random numbers in naked wars to make sure both computers generate the same results. If there was a problem I'm sure he'd have flagged the issue by now.

Anyway enough of me ranting. Your test is still valid I suppose as Blitz Max isn't Blitz3D. It just used to annoy me when everyone kept quoting an issue with Blitz3D's SeedRnd when there wasn't one. You should also have a Mac and Linux version to see if results are cross platform.

I don't know how that rumour started, but I challanged several forum members on the issue and not one of them could produce an incorrectly working example of SeedRnd in Blitz3D
It was a guy called Morduun who was on about it quite a lot.

I never proved it either - in fact I argued the opposite. However, I did note that Blitz3D and BlitzPlus gave different results using identical test code.

Vic 3 Babes had a problem with Random Seeds with BlitzPlus.

http://www.blitzbasic.com/Community/posts.php?topic=67003

Mordduns code is available for download with the link I provided in that thread.

Is Vic 3 Babes problem kind of what you guys mean and want to avoid?

The problem with random numbers in Blitz3D came from a change that was made between two versions of the program. I used a form of random number encryption on the level files for one of my games, which stopped working following a version change of Blitz3D. There was a simple fix to get the files readable again, but that's the only issue I am aware of. Not so much a different sequence on different PCs, but more if a program was compiled in a different version of Blitz3D itself.

Kanati's modules are talked about here: http://www.blitzbasic.com/Community/posts.php?topic=63234. I'm assuming that the Mersenne Twister modules is cross-platform, although I haven't got around to testing this yet. The module works, just not checked the sequences.