Horde3D

Next-Generation Graphics Engine
It is currently 22.11.2024, 00:10

All times are UTC + 1 hour




Post new topic Reply to topic  [ 4 posts ] 
Author Message
PostPosted: 05.04.2009, 16:44 
Offline

Joined: 21.08.2008, 11:44
Posts: 354
Im always getting [exactly] same sort of numbers using rand() [math.h]. Any body knows how to generate random numbers?


Last edited by Siavash on 05.04.2009, 19:49, edited 1 time in total.

Top
 Profile  
Reply with quote  
PostPosted: 05.04.2009, 16:47 
Offline

Joined: 22.11.2007, 17:05
Posts: 707
Location: Boston, MA
Siavash wrote:
Im always getting [exactly] same sort of numbers using rand() [math.h]. Any body knows how to generate random numbers?
Use srand() to set a seed. By default, the same seed is used every time, so the same sequence of random numbers is generated. A good choice for the random seed is the current time (i.e. gettimeofday() on linux/mac).

_________________
Tristam MacDonald - [swiftcoding]


Top
 Profile  
Reply with quote  
PostPosted: 05.04.2009, 19:48 
Offline

Joined: 21.08.2008, 11:44
Posts: 354
Thanks a lot for help :wink:


Top
 Profile  
Reply with quote  
PostPosted: 09.04.2009, 05:19 
Offline

Joined: 08.11.2006, 03:10
Posts: 384
Location: Australia
yeah, the line of code that I remember learning was: srand( time(NULL) );


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 18 guests


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 post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group