home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #30 / NN_1992_30.iso / spool / comp / lang / pascal / 7513 < prev    next >
Encoding:
Internet Message Format  |  1992-12-16  |  1.4 KB

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