Advertisement

tut 19 particle engine

Started by September 26, 2005 03:50 PM
3 comments, last by eSCHEn 19 years, 5 months ago
I noticed that the random numbers in this tut are never seeded. Yet, when I seeded them, I noticed little difference in the results. Does this mean I put the seed in the wrong spot (beginning of winmain) or are there so many particles that it makes little noticeable difference? From my experience in random numbers in the dos console, not seeding them generally resulted in "random numbers" that always showed the same numbers each time it ran through.
Random numbers are not truely random but rather pseudo-random and will produce the same sequence given the same seed, so the question I would ask is how are you seeding them?
--
Cheers,
Darren Clark
Advertisement
eSCHEn is correct

You should seed with time, I do

time.h
srand( (unsigned)time( NULL ) ); //New random seed

#include <ctime> /*** skipping code ***/int WINAPI WinMain(	HINSTANCE	hInstance,		        // Instance			        HINSTANCE	hPrevInstance,		// Previous Instance			        LPSTR		lpCmdLine,		// Command Line Parameters			        int		nCmdShow)		// Window Show State{	MSG	    msg;						// Windows Message Structure	BOOL	done=FALSE;						// Bool Variable To Exit Loop	srand(time(NULL));


The above shows that I included ctime, and where I placed srand, and that I used srand(time(NULL)). The only difference is that I'm excluding the unsigned variable.
I guess your question is partially my fault, since I excluded any snippets.

It is possible, though, that maybe it is random, and that I'm just not observant enough to compare when it's seeded and not seeded.
To convince yourself you could quickly knock up a wee test application in console mode and output a list to the console and compare results.
--
Cheers,
Darren Clark

This topic is closed to new replies.

Advertisement