Jump to content
• Advertisement
• entries
152
• comments
85
• views
100105

# Randomization

172 views

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!

## Recommended Comments

In Code Complete 2nd Edition, there's a useful random number class in there, you should check it out.

#### Share this comment

##### Link to comment
Check out Mersenne Twister, it's the best I know of. Fast too, if that's important to you.

## Create an account or sign in to comment

You need to be a member in order to leave a comment

## Create an account

Sign up for a new account in our community. It's easy!

Register a new account

## Sign in

Already have an account? Sign in here.

Sign In Now
• Advertisement
• Advertisement
• ### Blog Entries

• Advertisement
×

## Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!