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)

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #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
 


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 11:43 AM.


 

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