home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!ogicse!emory!ncratl!hroth
- From: hroth@ncratl.AtlantaGA.NCR.COM (Harris Roth)
- Newsgroups: comp.lang.pascal
- Subject: Re: help with die rolls...
- Message-ID: <77611@ncratl.AtlantaGA.NCR.COM>
- Date: 16 Dec 92 16:24:07 GMT
- Article-I.D.: ncratl.77611
- References: <1992Dec16.170959.3637@csdvax.csd.unsw.edu.au>
- Organization: NCR Engineering and Manufacturing Atlanta -- Atlanta, GA
- Lines: 26
-
- In article <1992Dec16.170959.3637@csdvax.csd.unsw.edu.au> p2112899@csdvax.csd.unsw.edu.au writes:
- >Could someone please show me how to get random die rolls going.
- >The code I have done is:
- >for i := 0 to 3 do pe := pe + random(6);
- >to roll a 6 sided die 3 times, but it doesn't work as it should. Some values
- >produced are actually lower than possible.
- >The minimum roll from 3 six sided die is 3, sometimes I get 2???
- >Richard.
- >P2112899@csdvax.csd.unsw.edu.au
-
- The random(6) call will produce an integer from 0 to 5. Your for statement
- will roll 4 times. Try this:
-
- pe := 0; (* initialize roll total *)
- for i := 1 to 3 do (* roll three times *)
- pe := pe + (random(6) + 1); (* total each roll *)
-
- Regards,
-
- Harris.
-
- --
- Harris J. Roth, Senior Programmer Analyst |
- System Software | hroth@ncratl.atlantaga.NCR.COM
- Transaction Terminal Systems Division |
- NCR E&M Atlanta | (404) 623-7749
-