| View previous topic :: View next topic |
| Author |
Message |
DarkOmen How do I cheat?
Reputation: 0
Joined: 28 Aug 2007 Posts: 2
|
Posted: Tue Aug 28, 2007 8:25 pm Post subject: [Help] C++ Random Number Generator Help |
|
|
Hey everyone, this is my first post so just saying hi.
Ok, down to business.
I'm trying to make a crappy text-based RPG in Visual C++. This game requires the use of a random number generator to generator a random number that decides what monster you get attacked by. The problem is, everything I've tried so far always produces a series of numbers that either;
repeat after a few have been generated, increase by 1, decrease by 1, or a something else that makes them predictable after a few are generated.
If anyone knows how to produce REAL random numbers that don't appear in a series, could you please let me know how?
Thanks
|
|
| Back to top |
|
 |
DeltaFlyer Grandmaster Cheater
Reputation: 0
Joined: 22 Jul 2006 Posts: 666
|
Posted: Tue Aug 28, 2007 8:36 pm Post subject: |
|
|
It's impossible to produce "REAL random numbers" with a computer. The computer is incapable of doing things randomly. The closest computers could get is pseudo-random, things that appear to be random but is actually generated by a function.
Use the functions on this page to generate pseudo-random numbers.
http://www.daniweb.com/forums/thread1769.html
Don't forget to seed the function first.
_________________
Wow.... still working at 827... what's INCA thinking?
zomg l33t hax at this place (IE only). Over 150 people have used it, what are YOU waiting for? |
|
| Back to top |
|
 |
Noz3001 I'm a spammer
Reputation: 26
Joined: 29 May 2006 Posts: 6220 Location: /dev/null
|
Posted: Wed Aug 29, 2007 3:00 am Post subject: |
|
|
| Code: | srand(time(NULL));
int Number = rand(); |
|
|
| Back to top |
|
 |
Noz3001 I'm a spammer
Reputation: 26
Joined: 29 May 2006 Posts: 6220 Location: /dev/null
|
Posted: Wed Aug 29, 2007 5:14 pm Post subject: |
|
|
| DarkOmen wrote: | | noz3001 wrote: | | Code: | srand(time(NULL));
int Number = rand(); |
|
I need the numbers generated to be within a specific range. |
| Code: | srand(time(NULL));
int Number = rand() % 100; |
|
|
| Back to top |
|
 |
AnonymousX How do I cheat?
Reputation: 0
Joined: 17 Mar 2007 Posts: 8
|
|
| Back to top |
|
 |
|