Go Back   RunUO - Ultima Online Emulation > RunUO > Modification Suggestions

Modification Suggestions This is where you can suggest a modifcation to RunUO!

Reply
 
Thread Tools Display Modes
Old 06-10-2006, 02:09 AM   #1 (permalink)
Newbie
 
Join Date: Jan 2006
Age: 32
Posts: 45
Default Error in Utility.Random...Methods?

Im just curious of the Utility.Random Methods are working correctly or not. How are these derived? I feel they are running off the system clock cycle. If this is true, then I dont think this is the best way to run this. It could potentially cause Errors in the Hitting Effects, spell casting, or anything else that runs the Utility.Random Methods. I guess what im asking is if your running a Random Seed or if your running off the system clock.


I only ask this because people tend to Hit 5x in a row, then miss 5 or more times, hit 1 time, miss 10 times, hit 10 times, miss 1 time..ect.

Something just seems fishy about this. And since most of your code runs off the Utility.RandomDouble() stuff. Is it possible that there is no randomseed generation? How many Cycles does it take for the System to Generate a random item? If it dont take but x amount of cycles. If its running off the clock. and the item is generated at 0.0002302 then ends at .0005323? The random function isnt really doing its job. This is just my thoughts on whats actually going on. Didnt know if this was worth looking into.

Thanks for reading.
ABCGizmo is offline   Reply With Quote
Old 06-10-2006, 02:40 AM   #2 (permalink)
Account Terminated
 
Join Date: Sep 2002
Age: 26
Posts: 3,846
Send a message via ICQ to Phantom Send a message via AIM to Phantom Send a message via MSN to Phantom
Default

The random functions work exactly like they should.

If you have code that you think that is not working, then it might be the code that is the problem, I will say that the default code uses the methods in the correct way.
Phantom is offline   Reply With Quote
Old 06-10-2006, 02:53 AM   #3 (permalink)
Newbie
 
Join Date: Jan 2006
Age: 32
Posts: 45
Default

Quote:
Originally Posted by Phantom
The random functions work exactly like they should.

If you have code that you think that is not working, then it might be the code that is the problem, I will say that the default code uses the methods in the correct way.
I guess the distro files dont work right then is what your saying?
ABCGizmo is offline   Reply With Quote
Old 06-10-2006, 10:05 AM   #4 (permalink)
Forum Expert
 
o0_Sithid_0o's Avatar
 
Join Date: Nov 2004
Location: Hiding his old posts from Daat99.
Age: 22
Posts: 2,309
Send a message via AIM to o0_Sithid_0o Send a message via MSN to o0_Sithid_0o
Default

Quote:
Originally Posted by ABCGizmo
I guess the distro files dont work right then is what your saying?
Quote:
Originally Posted by Phantom
The random functions work exactly like they should.

If you have code that you think that is not working, then it might be the code that is the problem, I will say that the default code uses the methods in the correct way.

Notice the bolded word?
__________________

Quote:
Originally Posted by Radwen View Post
Give me a reason... to like you.
Quote:
Originally Posted by excuse me miss, but uh... View Post
11/f/n.korea
Priceless.
o0_Sithid_0o is offline   Reply With Quote
Old 06-10-2006, 01:16 PM   #5 (permalink)
Account Terminated
 
Join Date: Sep 2002
Age: 26
Posts: 3,846
Send a message via ICQ to Phantom Send a message via AIM to Phantom Send a message via MSN to Phantom
Default

Plus the part where I said I know the random function in the default code were used in the correct way.

So everyone knows is the Utility's Random functions use the .NET Framework code to generate random numbers. Its just has specfic methods to generate numbers specfic for our use.

I doubt that they use randomseed generation method, considering thats stuff that companies pay alot of money for since the calculations are so advanced. Plus the fact you wouldn't really want that code, since it would take so much system resouces to calculate a "fake" random number.

Clearly a computer cannot generate a "true" random number, there will always be what appears to be a "pattern" since its just how the computer works.
Phantom is offline   Reply With Quote
Old 06-10-2006, 01:42 PM   #6 (permalink)
Forum Expert
 
arul's Avatar
 
Join Date: Jan 2005
Location: Hiding in your room.
Age: 21
Posts: 1,272
Send a message via MSN to arul
Default

They use system time (tickcount) when the class was instantiated as seed, but over the time when you call one of these methods the internal seed changes.

Next();
Next(int maxValue);
Next(int minValue, int maxValue);
NextBytes(byte[] buffer);
NextDouble();

More information here http://msdn2.microsoft.com/en-us/lib...em.random.aspx
__________________
arul is offline   Reply With Quote
Old 06-10-2006, 06:13 PM   #7 (permalink)
Account Terminated
 
Join Date: Sep 2002
Age: 26
Posts: 3,846
Send a message via ICQ to Phantom Send a message via AIM to Phantom Send a message via MSN to Phantom
Default

Quote:
Originally Posted by arul
They use system time (tickcount) when the class was instantiated as seed, but over the time when you call one of these methods the internal seed changes.

Next();
Next(int maxValue);
Next(int minValue, int maxValue);
NextBytes(byte[] buffer);
NextDouble();

More information here http://msdn2.microsoft.com/en-us/lib...em.random.aspx
You quoted the wrong version of the .NET Framework :-)

I wasn't really postive of which method was used, I just know it works as well as it should, since I have used the random generation in VB .NET back in 2001
Phantom is offline   Reply With Quote
Old 06-15-2006, 11:13 AM   #8 (permalink)
Newbie
 
Join Date: Jan 2006
Posts: 44
Default

I've noticed the same thing... casting ev's I'll fizzle 5 times, then cast 4 times. I think the random utility should just be replaced with the systime, and use the modulous function to get a number between 0-100

Everything that has a % chance of being successful could then be compared to that number. If the % chance is higher than the "random" number returned, then the attempt was a success.

And by systime I mean the timer that gives you thousandths of a second.
iwantmypot is offline   Reply With Quote
Old 06-16-2006, 05:15 PM   #9 (permalink)
Administrator
 
Zippy's Avatar
 
Join Date: Aug 2002
Location: Baltimore, MD
Age: 25
Posts: 4,832
Default

Quote:
Originally Posted by iwantmypot
I've noticed the same thing... casting ev's I'll fizzle 5 times, then cast 4 times. I think the random utility should just be replaced with the systime, and use the modulous function to get a number between 0-100

Everything that has a % chance of being successful could then be compared to that number. If the % chance is higher than the "random" number returned, then the attempt was a success.

And by systime I mean the timer that gives you thousandths of a second.
That is probably the worst idea ever. This would actually AMPLIFY your problem, not make it better.

The internal random number generator is working perfectly fine. Just because it sometimes "feels" like its not random doesn't mean its true.
__________________
Zippy, Razor Creator and RunUO Core Developer
The RunUO Software Team

"Intuition, like a flash of lightning, lasts only for a second. It generally comes when one is tormented by a difficult decipherment and when one reviews in his mind the fruitless experiments already tried. Suddenly the light breaks through and one finds after a few minutes what previous days of labor were unable to reveal."
~The Cryptonomicon

Zippy is offline   Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off



Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0 RC5