Go Back   EQEmulator Home > EQEmulator Forums > Development > Development::Development

Development::Development Forum for development topics and for those interested in EQEMu development. (Not a support forum)

Reply
 
Thread Tools Display Modes
  #1  
Old 05-23-2008, 11:07 AM
Wolftousen
Sarnak
 
Join Date: Apr 2008
Posts: 49
Default Random number generation

Ok, so I got tired of waiting for someone to respond on PEQ boards about the melee crit AAs not working properly. I have a 65 berserker and have bought all ranks of crit AAs through PoP, but I don't crit nearly often enough when compared to live.

So, i looked through the server code and low and behold found the problem. It has little to nothing to do with the crit AAs it actually is how random numbers are being generated. Srand and Rand are built into C for convenience and are actually horrible and slow methods to getting random numbers. Very very far from being true random...

I would suggest using this instead:
http://www-personal.umich.edu/~wagne...neTwister.html

This is probably causing issues with a lot of other stuff, like the PoP parchment turn ins for spells that give you the same spells over and over b/c it seems like they aren't balanced. It is because of srand/rand...

This should help...
Reply With Quote
  #2  
Old 05-23-2008, 01:56 PM
Bulle
Hill Giant
 
Join Date: Jan 2008
Posts: 102
Default

There is also the one from the GNU (gsl if my memory is right) which I have integrated in my custom server, through hooks. Supposed to be a "fair" one. It works, though it is hard to tell whether it is better than the original, it has its long streaks of "You miss" too, if you see what I mean...
Reply With Quote
  #3  
Old 05-23-2008, 02:37 PM
Wolftousen
Sarnak
 
Join Date: Apr 2008
Posts: 49
Default

Yeah, any number generator is going to have that every once in a while. But srand/rand is just appalling and is not by any means a good way to do it. I have my misses turned off, so i dunno about that. But having a 20% chance to crit and not critting more than maybe 1 time every 20 swings isn't right. I did the etheral parchment turn in maybe 40some times and got the same 3 spells 32 of those times, mostlikely b/c they are on one of the extreme ends of the % chance... Also, mobs on PEQ with a 50/50 drop rate for an item that end up dropping one way more often than the other is another indicator of bad randomization...
Reply With Quote
  #4  
Old 05-23-2008, 02:54 PM
jenco420
Banned
 
Join Date: Jan 2006
Location: /dev/null
Posts: 99
Default

I'm just being funny, but does'nt EQlive have a horrible RNG? :P
Reply With Quote
  #5  
Old 06-03-2008, 07:06 PM
BatCountry
Fire Beetle
 
Join Date: Mar 2006
Posts: 24
Default

The problem with C's rand() function that's always trumpeted as being a "bad RNG" is not because it doesn't have a fair distribution - it does, when used properly.

The problem with C's rand() function is that it's predictable, so it's unsuitable for cryptography. Your attack rolls do not need to be cryptographically secure. The same RNG is in use in most every computer game you've ever played.

A quick test case run with 5 million iterations generating a number between 1 and 20 using srand(time(NULL)) at the beginning of execution and ((rand()/RAND_MAX)*20+1) shows that each number comes up no more than 0.02% deviation from the appropriate 5% of the time. (This is on a Windows XP platform, using MSVC++ 2005)

The distribution is fair. If it seems like you're critting too infrequently, don't blame the RNG, take a look at the calculations to make sure that all the AAs you think you've got are actually implemented yet.
Reply With Quote
  #6  
Old 06-03-2008, 07:13 PM
BatCountry
Fire Beetle
 
Join Date: Mar 2006
Posts: 24
Default

Incidentally, those 5 million iterations took 2.65 seconds on a 2ghz Athlon XP which is already running EQEmu in the background and Remote Desktop.
Reply With Quote
Reply


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

Forum Jump

   

All times are GMT -4. The time now is 12:27 PM.


 

Everquest is a registered trademark of Daybreak Game Company LLC.
EQEmulator is not associated or affiliated in any way with Daybreak Game Company LLC.
Except where otherwise noted, this site is licensed under a Creative Commons License.
       
Powered by vBulletin®, Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Template by Bluepearl Design and vBulletin Templates - Ver3.3