| Mirage Source http://miragesource.net/forums/ |
|
| Noob with Rnd? http://miragesource.net/forums/viewtopic.php?f=201&t=2047 |
Page 1 of 1 |
| Author: | Rezeyu [ Thu Jun 14, 2007 11:24 am ] |
| Post subject: | Noob with Rnd? |
I noticed everytime I used rnd in the client is was giving me a set pattern.. I used: Int(Rnd * 4) + 1 And it always gave me this order: 3 - 3 - 3 - 2 - 2 - 4 - 1 - 4 - 4 - 3 No matter what. I don't understand, and it's driving me nuts. It works fine in the server. Makes no sense. Blah. |
|
| Author: | Verrigan [ Thu Jun 14, 2007 11:25 am ] |
| Post subject: | Re: Noob with Rnd? |
Place Code: Randomize Timer before you use Rnd().
|
|
| Author: | Rezeyu [ Thu Jun 14, 2007 11:31 am ] |
| Post subject: | Re: Noob with Rnd? |
I put it in Sub Main now, thnx Verrigan. |
|
| Author: | Verrigan [ Thu Jun 14, 2007 11:32 am ] |
| Post subject: | Re: Noob with Rnd? |
Not a problem.. Easy thing to over-look. |
|
| Author: | Rezeyu [ Thu Jun 14, 2007 11:39 am ] |
| Post subject: | Re: Noob with Rnd? |
Well now that it got me thinking about it, why dos it produce that pattern when it's not randomized? |
|
| Author: | Verrigan [ Thu Jun 14, 2007 11:46 am ] |
| Post subject: | Re: Noob with Rnd? |
It's a pseudo-random number generator. It does various calculations on a 'salt' and then changes that salt. If you don't set the salt to a new base number, it always starts out as the same salt, and therefore, you always get the same sequence of numbers.. Timer is a constantly changing value, so using Timer as the salt gives you a fresh, new number every time you use it, and hence, your random numbers look more random. |
|
| Author: | Rezeyu [ Thu Jun 14, 2007 11:49 am ] |
| Post subject: | Re: Noob with Rnd? |
Hah, alright, makes sense then. I knew that the rnd function ran off a base apttern of some sort, becasue I remember being told it's not 'perfectly' random. The timer bit makes perfect sense now. Thanks again. I needed it client side because everytime you login it displays a new game tip. |
|
| Author: | Coke [ Thu Jun 14, 2007 1:14 pm ] |
| Post subject: | Re: Noob with Rnd? |
That sounds leet :O |
|
| Author: | Robin [ Thu Jun 14, 2007 2:12 pm ] |
| Post subject: | Re: Noob with Rnd? |
Fox wrote: That sounds leet :O I am sooo stealing that idea. *opens up VB* |
|
| Author: | Matt [ Thu Jun 14, 2007 7:10 pm ] |
| Post subject: | Re: Noob with Rnd? |
Most of the commercial mmo games have that. Took awhile for Lineage 2 to get it, but they put that in when they released C5. Not an original idea, but it is an original MS idea. |
|
| Author: | Dragoons Master [ Sat Jun 16, 2007 3:02 am ] |
| Post subject: | Re: Noob with Rnd? |
Verrigan, I always used just "Randomize", without Timer. What seed it uses I use only "Randomize"? |
|
| Author: | Verrigan [ Sat Jun 16, 2007 6:52 am ] |
| Post subject: | Re: Noob with Rnd? |
Type 'Randomize' in your VB code window, on any form.. Preferrably in a function, sub, or property, and press F1. If you don't have MSDN Help installed, shame on you. |
|
| Author: | Dragoons Master [ Sat Jun 16, 2007 12:40 pm ] |
| Post subject: | Re: Noob with Rnd? |
I do have, but I'm not at home right now xD I'm at college and I'll go homeonly tonight. Well, anyway, I'll take a look tonight |
|
| Page 1 of 1 | All times are UTC |
| Powered by phpBB® Forum Software © phpBB Group https://www.phpbb.com/ |
|