Author |
Message |
Bak ?ls -s 0 in

Age:26 Gender: Joined: Jun 11 2004 Posts: 1826 Location: USA Offline
|
Posted: Thu Oct 21, 2004 11:12 pm Post subject: |
 |
|
|
|
// Seed random number generator (do once when program starts)
void seedRandom()
{
srand(time(0));
}
// Get a random number between lowerBound and upperBound, inclusive
// so getRandomNumber(2,4) will return 2, 3, or 4
// if your range is invalid (lowerBound < upperBound) returns -1
int getRandomNumber(int lowerBound, int upperBound)
{
int range = upperBound - lowerBound + 1;
int rv = -1;
if (range > 0)
{
rv = lowerBound + rand() % range;
}
return rv;
} |
And make sure in your code you call seedRandom() once when the program starts (or in the botInfo constructor) and use getRandomNumber(2,85); to get a random number between 2 and 85, inclusive.
so like:
sendPrivate(p,"*setfreq " + (String)getRandomNumber(2,85));
where p is a Player* |
|
Back to top |
|
 |
Mine GO BOOM Hunch Hunch What What

Age:41 Gender: Joined: Aug 01 2002 Posts: 3615 Location: Las Vegas Offline
|
|
Back to top |
|
 |
Bak ?ls -s 0 in

Age:26 Gender: Joined: Jun 11 2004 Posts: 1826 Location: USA Offline
|
|
Back to top |
|
 |
Mr Ekted Movie Geek

Gender: Joined: Feb 09 2004 Posts: 1379 Offline
|
Posted: Fri Oct 22, 2004 2:52 pm Post subject: |
 |
|
|
|
Thank you Bak for your sanity in times of chaos (MGB and UL).  _________________ 4,691 irradiated haggis! |
|
Back to top |
|
 |
Cyan~Fire I'll count you!

Age:37 Gender: Joined: Jul 14 2003 Posts: 4608 Location: A Dream Offline
|
Posted: Fri Oct 22, 2004 5:24 pm Post subject: |
 |
|
|
|
You call that sanity?! _________________ This help is informational only. No representation is made or warranty given as to its content. User assumes all risk of use. Cyan~Fire assumes no responsibility for any loss or delay resulting from such use.
Wise men STILL seek Him. |
|
Back to top |
|
 |
Mr Ekted Movie Geek

Gender: Joined: Feb 09 2004 Posts: 1379 Offline
|
Posted: Fri Oct 22, 2004 7:02 pm Post subject: |
 |
|
|
|
I was willing to ignore that transgression for the greater good.  |
|
Back to top |
|
 |
Underlord Novice
Gender: Joined: Feb 17 2004 Posts: 55 Offline
|
|
Back to top |
|
 |
50% Packetloss Server Help Squatter

Age:40 Gender: Joined: Sep 09 2003 Posts: 561 Location: Santa Clarita, California Offline
|
Posted: Fri Oct 22, 2004 9:23 pm Post subject: |
 |
|
|
|
Just hook your bot up to this random number generator
 |
|
Back to top |
|
 |
Dr Brain Flip-flopping like a wind surfer

Age:39 Gender: Joined: Dec 01 2002 Posts: 3502 Location: Hyperspace Offline
|
Posted: Fri Oct 22, 2004 9:39 pm Post subject: |
 |
|
|
|
How random "random" really is doesn't matter in this case. It's not like he's using this for encryption. _________________ Hyperspace Owner
Smong> so long as 99% deaths feel lame it will always be hyperspace to me |
|
Back to top |
|
 |
|