Randomization

Published August 12, 2005
Advertisement
Well, I've finally gotten some time in working on C.F.L. a bit more today. There really is a hell of a lot to do. At any rate, I have a selection structure for a trivia element with 500 questions listed in it ranging through about ten different categories.

I spent about an hour or so looking into better pseudo-random number generation today. My main source was Mathmatical Techniques from the Infinite Game Universe series by Guy W. Lecky - Thompson. Although he goes over two algorithms and seeding, which I've had an understanding of for sometime, I couldn't really find any useful information. Aside from creating various switch statements that use various ranges of numbers to come up with a random total, I can't seem to come up with a good approach to finding an algorithm that works very well at all. Everytime I run through that segment of the game, it seems that the results tend to be more in the first one hundred questions then anywhere else, this is probably about eighty percent or more of the time. I suppose I'm wondering if anyone out there has a solution to better randomization of numbers, or can point me in the right direction. Thanks in advance if you can help, if not :p.


EDIT: I suppose I should say that I am using the rand() function with srand based on time, actually here is the code. What the F@# I just realized what the problem has been all this time, I only have a total of one hundred instead of five hundred in my random number generation. That explains a lot. DOH!
Next Entry Ha ha
0 likes 2 comments

Comments

BDePesa
In Code Complete 2nd Edition, there's a useful random number class in there, you should check it out.
August 13, 2005 04:32 AM
Rixter
Check out Mersenne Twister, it's the best I know of. Fast too, if that's important to you.
August 15, 2005 03:31 PM
You must log in to join the conversation.
Don't have a GameDev.net account? Sign up!
Advertisement
Advertisement