• Welcome to Valhalla Legends Archive.
 

Curious: Randomization

Started by FrostWraith, September 11, 2006, 08:12 PM

Previous topic - Next topic

FrostWraith

How is this achieved. I have all these fine a dandy function to call.  Could anyone show a way, if possible, this could be done in VB?

Joe[x86]

What do you want to randomize? For a number between zero and 100, use this code.

Function Random1to100()
    Randomize
    Random1to1000 = Int(Rnd * 100)
End Function
Quote from: brew on April 25, 2007, 07:33 PM
that made me feel like a total idiot. this entire thing was useless.

MyndFyre

Except replace Random1to1000 with Random1to100
QuoteEvery generation of humans believed it had all the answers it needed, except for a few mysteries they assumed would be solved at any moment. And they all believed their ancestors were simplistic and deluded. What are the odds that you are the first generation of humans who will understand reality?

After 3 years, it's on the horizon.  The new JinxBot, and BN#, the managed Battle.net Client library.

Quote from: chyea on January 16, 2009, 05:05 PM
You've just located global warming.

Hero

Quote from: FrostWraith on September 11, 2006, 08:12 PM
How is this achieved. I have all these fine a dandy function to call.  Could anyone show a way, if possible, this could be done in VB?

Int(Rnd * Max #)

l2k-Shadow

#4
i like this function i wrote:

Public Function Rand(ByVal lFrom As Long, ByVal lTo As Long) As Long
    Call Randomize
    Rand = lFrom + Int((Rnd * ((lTo + 1) - lFrom)))
End Function
Quote from: replaced on November 04, 2006, 11:54 AM
I dunno wat it means, someone tell me whats ix86 and pmac?
Can someone send me a working bot source (with bnls support) to my email?  Then help me copy and paste it to my bot? ;D
Já jsem byl určenej abych tady žil,
Dával si ovar, křen a k tomu pivo pil.
Tam by ses povídaj jak prase v žitě měl,
Já nechci před nikym sednout si na prdel.

Já nejsem z USA, já nejsem z USA, já vážně nejsem z USA... a snad se proto na mě nezloběj.

FrostWraith

No no no. I meant how does this function even work. Like, how would you write code that can randomize. I'm talking about the actual function that does the randomizing (Randomize). Would it be hard to write a new one?

FrOzeN

Have a read over this, http://computer.howstuffworks.com/question697.htm

The function Rnd([number]) in VB6 is similar to the code in that article,
Quoteint rand()
{
  random_seed = random_seed * 1103515245 +12345;
  return (unsigned int)(random_seed / 65536) % 32768;
}
And the function Randomize([number]) generates a new seed. Not sure about where it gets the seed from, but it's probably a combination of the time, mouse cursor, etc. Also, you can use the optional property [number] to define what you want the seed to be. This property also exists in the Rnd() function, I'm not sure of what it does, but it's probably to do with modifying the seed aswell.
~ FrOzeN

MyndFyre

Quote from: FrostWraith on September 12, 2006, 04:07 AM
No no no. I meant how does this function even work. Like, how would you write code that can randomize. I'm talking about the actual function that does the randomizing (Randomize). Would it be hard to write a new one?
Numbers generated by computers are typically not truly random but really use a pseudorandom number generator, which is a deterministic function.  If you were to give the generator the same seed repeatedly, you would see the same sequence of numbers generated by the random number generator.
QuoteEvery generation of humans believed it had all the answers it needed, except for a few mysteries they assumed would be solved at any moment. And they all believed their ancestors were simplistic and deluded. What are the odds that you are the first generation of humans who will understand reality?

After 3 years, it's on the horizon.  The new JinxBot, and BN#, the managed Battle.net Client library.

Quote from: chyea on January 16, 2009, 05:05 PM
You've just located global warming.

K

Quote from: MyndFyre[vL] on September 12, 2006, 02:08 PM
If you were to give the generator the same seed repeatedly, you would see the same sequence of numbers generated by the random number generator.

Which is actually not true with the Randomize() function.  Successive calls to Randomize with the same value will not result in generating the same numbers with Rnd() unless you first call Rnd() with a negative number to indicate that this is what you wish to acheive.