Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Code Snippets / [GDK] Better Random Int Generator

Author
Message
Mason
20
Years of Service
User Offline
Joined: 20th Mar 2004
Location: Arizona
Posted: 22nd Feb 2008 04:35 Edited at: 22nd Feb 2008 04:44
While working on a program for the GDK Challenge thread, I realized how aweful dbRnd() is. I noticed that every time I run the program, it produces the same set of random integers. This wasn't going to work for my program so I set out and found a way to code another int generator.

I found a nice site (which I give credit too in the function) that explained how to make one so I coded it out. Unfortunately it had about the same effect as dbRnd(), so I made some changes. Below is a simple but powerful little int generator. Use it as you please, imo, a much better substitute to dbRnd. Enjoy

In order to run this code, you must include cstdlib & time.h


And here is a sample program to see how its used.




Zotoaster
19
Years of Service
User Offline
Joined: 20th Dec 2004
Location: Scotland
Posted: 22nd Feb 2008 16:00
dbRandomizeTimer() will give you unique random numbers everytime.

Don't you just hate that Zotoaster guy?
Mason
20
Years of Service
User Offline
Joined: 20th Mar 2004
Location: Arizona
Posted: 23rd Feb 2008 05:15
Wow cool, didn't know that with all my Dark Basic years too lol. Oh well, I'll use mine


Login to post a reply

Server time is: 2024-05-17 06:25:10
Your offset time is: 2024-05-17 06:25:10