UOGamers Community

This is a sample guest message. Register a free account today to become a member! Once signed in, you'll be able to participate on this site by adding your own topics and posts, as well as connect with other members through your own private inbox!

  • To obtain new Razor updates, please reinstall Razor from our new website.

Riddle

Riddle

I wrote a my own random number generator in C#. When I ran it, it produced the same number multiple times and did not produce another number before I stopped testing it. It does not have a specifiable range. It simply produces a random number between 1 and the maximum value an integer can hold, somewhere in the neighborhood of 4 billion.

Is my random number generator broken?
 

Muggz

Sorceror
...

no!!!!!

you just have it set to pick a random number between X and Y and X = Y so you get the same number every time!

what do i win?
 
Muggz said:
no!!!!!

you just have it set to pick a random number between X and Y and X = Y so you get the same number every time!

what do i win?

Nope. The random generator does not have a specifiable range. I've edited the original post to clarify this.
 
are you using a variable within the generator that isn't being reset on each use.

ie
if x isnull then
-=random number generator code here=-
set x = random number
return x

since x has been set, this code wouldn't overwrite the variable...hence returning the same number everytime
 
xeres said:
are you using a variable within the generator that isn't being reset on each use.

ie
if x isnull then
-=random number generator code here=-
set x = random number
return x

since x has been set, this code wouldn't overwrite the variable...hence returning the same number everytime

Nope. The random number generator simply picks a number between 1 and 4 billion, and spits it out. There's no variable trickery in it.
 
Drag said:
No it isn't broken. You're just lucky as hell ;)

How do you know it isn't broken though? If I keep getting the same number, the odds the next number is the same decreases exponentially. Surely I'd get a different number.

;)
 

Rhun-demise

Wanderer
Is this really a riddle.. or do you need help ?? If it's a riddle I haven't an answer, if you need help give me the code and I'll help you :)
 
I was wondering the same thing too... I was all "Oh yeah a riddle" lets get my thinking cap... but nooooo all i get is coded # scripting stuff that makes no sense.
 

[Drakull]

Knight
Did you initiated the ramdom numbers generator before trying to obtain the numbers? what's the delay between each try?
 
Drakull said:
Did you initiated the ramdom numbers generator before trying to obtain the numbers? what's the delay between each try?

C# aien't my main language, but in c,c++ u do need todo as Drakull says

just read the current system time, and use it at seed value. then do the random () % max+1

so yes it's broken :)
 

jacin

Wanderer
no. its never 0 chance of getting any number (even the same one over and over again.). just like flipping coin, 1 of two outcomes each time doesnt mean you wont get heads everytime.
 
Top