Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


[Help] C++ Random Number Generator Help

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
DarkOmen
How do I cheat?
Reputation: 0

Joined: 28 Aug 2007
Posts: 2

PostPosted: Tue Aug 28, 2007 8:25 pm    Post subject: [Help] C++ Random Number Generator Help Reply with quote

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
View user's profile Send private message
DeltaFlyer
Grandmaster Cheater
Reputation: 0

Joined: 22 Jul 2006
Posts: 666

PostPosted: Tue Aug 28, 2007 8:36 pm    Post subject: Reply with quote

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
View user's profile Send private message
Noz3001
I'm a spammer
Reputation: 26

Joined: 29 May 2006
Posts: 6220
Location: /dev/null

PostPosted: Wed Aug 29, 2007 3:00 am    Post subject: Reply with quote

Code:
srand(time(NULL));
int Number = rand();
Back to top
View user's profile Send private message MSN Messenger
Noz3001
I'm a spammer
Reputation: 26

Joined: 29 May 2006
Posts: 6220
Location: /dev/null

PostPosted: Wed Aug 29, 2007 5:14 pm    Post subject: Reply with quote

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
View user's profile Send private message MSN Messenger
AnonymousX
How do I cheat?
Reputation: 0

Joined: 17 Mar 2007
Posts: 8

PostPosted: Thu Aug 30, 2007 12:49 am    Post subject: Reply with quote

2 pages that should help you.

http://www.cplusplus.com/reference/clibrary/cstdlib/rand.html

http://www.cplusplus.com/reference/clibrary/cstdlib/srand.html
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites