TIP: Click on subject to list as thread! ANSI
echo: c_plusplus
to: JIM ROBIN
from: JOSHUA BOEHME
date: 1997-05-05 19:03:00
subject: Throw of dice

 While gazing into my crystal ball, I saw a message from Jim Robin to All 
 JR> I've got this friend who is constructing a dice game using Visual C++
 JR> where one of the required elements is to simulate the throwing of a
 JR> dice. 
 JR> To cut a long story short does anyone know of an algorithm that can
 JR> generate numbers between a lower bound value and an upper bound value
 JR> - in the case of the dice example 1 - 6.
 Your compiler should have a function called random() or something similar.
(written for Borland Turbo C++)
#include 
#include 
main()
{
randomize();  // Resets the random number generator seed using current time
int dice_roll = random(6) + 1; // Random(int mod) generates a random value
                               // between 0 and mod-1
}
--- FMail 1.02
---------------
* Origin: The misty isles of Stonegaia (1:159/600)

SOURCE: echomail via exec-pc

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.