123
-=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- (c) WidthPadding Industries 1987 0|115|0 -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=-
Socoder -> Blitz -> Perfectly Random Numbers?

Sat, 28 Nov 2009, 10:10
dna
I was looking at a algorithm for generating random numbers.

For many of the routines the result remains dependent upon the internal clock. If it turns over, or if the seed is the same then, you can reasonably predict the outcome.

AH.

What about this routine?



-=-=-
DNA
Sat, 28 Nov 2009, 10:33
Phoenix
I don't understand the question. If you're looking for an alternative random number generator, you may want to check out Evil Roy Ferguson's Mersenne Twister version.
Sat, 28 Nov 2009, 18:23
dna

That one is good but it requires B3D.

For any version of BB this one may be better.

-=-=-
DNA
Sat, 28 Nov 2009, 21:37
JL235
dna That one is good but it requires B3D.

You sure? I'd have presumed that you can load dll's in both B3D and BB. I always B3D was the same, just with the 3D library tacked on.
Sat, 28 Nov 2009, 22:19
JL235
dna That one is good but it requires B3D.

You sure? I'd have presumed that you can load dll's in both B3D and BB. I always B3D was the same, just with the 3D library tacked on.

But you will only ever get psudo-random through code. Computers cannot generate truly random numbers. If you do want them then you will need to grab them from a cache of pre-generated numbers. The numbers themselves are based on background radiation (but other measurements can also be used) which appeares to be random (although I doubt it truly is). See Random.org for me.

I personally though use a cheap psudo random number generator I built from the code in this topic on JavaGaming.org. However after just porting it to BB I find it's slower then BBs currently implemented random functions.

Finally your random function doesn't allow you to set or alter the seed value. This is very useful for games (and other apps) is it allows you to randomly generate the same data by just providing the same seed (like generating the same map for level 1 in a game).
Sat, 28 Nov 2009, 23:08
Stealth
I would like to point out that random numbers computers generate are generally random enough for us. Unless you're generating numbers for a lottery program, it's trivial to spend so much time on this.

-=-=-
Quit posting and try Google.
Sun, 29 Nov 2009, 08:55
Phoenix
Using the site JL235 suggested, you can send HTTP requests to get numbers. It's slow as hell, but it works if speed isn't critical.


Sun, 29 Nov 2009, 13:11
CodersRule
I've seen a different random number generator on the BB forums a long time ago, and the person was criticized because the Right() function takes too long.
But, like Stealth said, you'd only use this for something like a lottery system, in which speed isn't an issue.
Sun, 29 Nov 2009, 13:42
dna

Using a DLL in my version of BB is not possible since the function is not supported.

-=-=-
DNA
Sun, 29 Nov 2009, 14:56
Jayenkai


-=-=-
''Load, Next List!''
Sun, 29 Nov 2009, 16:17
dna

Good Jay.

But is there a way to get the same numbers out of the program?

What I mean is can the seed number be set to produce the same series of numbers.

-=-=-
DNA
Sun, 29 Nov 2009, 16:23
Jayenkai
Yeah, just SeedRnd #number.

If you want the player to think there's an ever growing random set of numbers, then interject things with a few additional rand's here and there. It won't ever be truely random, but at the end of the day there's still so many combinations that it doesn't really matter..

I mean, if you consider a real deck of cards, and every possibly shuffle, there's still a point where you'll start repeating yourself.

Pseudo's good enough!
No-one will care if it's not.


-=-=-
''Load, Next List!''
Mon, 30 Nov 2009, 03:15
Afr0
You could do the same thing as they've done on Random.org, more or less.
Generate lots and lots and lots of pseudo random numbers, store them in a database/file, and pick one at random!

The numbers from Random.org are probably more random, but accessing them online is slow and nedlessly complex.

Edit: By lots and lots and lots, I mean anywhere from 5000 to 10000 numbers.

Edit: Storing lots and lots and lots of random numbers can take alot of space, so you might want to compress your file/database. This will add to the time taken to select a random number, but still won't be as slow and needlessly complex as getting a random number from Random.org.

-=-=-
Afr0 Games

Project Dollhouse on Github - Please fork!
Mon, 30 Nov 2009, 06:07
JL235
The Random.org numbers aren't generated psudo-random numbers, they are recorded based on naturally occurring phenominons which are (so far) believed to be truly random. There is a difference.
Mon, 30 Nov 2009, 07:45
Afr0
The numbers themselves are based on background radiation (but other measurements can also be used) which appeares to be random (although I doubt it truly is)


-=-=-
Afr0 Games

Project Dollhouse on Github - Please fork!
Tue, 01 Dec 2009, 19:44
dna
jl235 Finally your random function doesn't allow you to set or alter the seed value. This is very useful for games (and other apps) is it allows you to randomly generate the same data by just providing the same seed (like generating the same map for level 1 in a game).


You right. I posted the code not to suggest replacing the internal bb generator.

Also. that story about the background radiation makes an interesting subject.

-=-=-
DNA