Skip to main content
gamedev.net
🔒 Locked

generating random numbers?

Started by jimiwa Jun 4, 2004 at 12:58 PM 3 replies 550+ views
Original Post
jimiwa
jimiwa
What function should I use to generate random numbers and how do I set the random number seed to the timer? I''m using Visual C++ .net, just in case that makes any difference (I don''t know if it does or not)
Fruny
Fruny
STFW.
"Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it." — Brian W. Kernighan
dave768k
dave768k
you use .NET, so just use the Random class, like this
Random rnd = new Random();
int i = rnd.Next(0, 9);

this will generate an integer between 0 and 9

[edited by - dave768k on June 4, 2004 2:20:18 PM]
Venerable Vampire
Venerable Vampire
or srandomdev() to seed it

--------------------------------------------------------
Life would be so much easier if we could just get the source code.
--------------------------------------------------------Life would be so much easier if we could just get the source code.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.