home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!cis.ohio-state.edu!pacific.mps.ohio-state.edu!linac!uwm.edu!ogicse!mimbres.cs.unm.edu!constellation!osuunx.ucc.okstate.edu!vms.ocom.okstate.edu!adams
- From: adams@vms.ocom.okstate.edu
- Newsgroups: comp.lang.pascal
- Subject: Re: help with die rolls...
- Message-ID: <1992Dec16.100336.1@vms.ocom.okstate.edu>
- Date: 16 Dec 92 16:03:36 GMT
- Article-I.D.: vms.1992Dec16.100336.1
- References: <1992Dec16.170959.3637@csdvax.csd.unsw.edu.au>
- Sender: news@osuunx.ucc.okstate.edu (USENET News System)
- Organization: OSU College of Osteopathic Medicine
- Lines: 38
- Nntp-Posting-Host: vms.ocom.okstate.edu
-
- 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.
- >
- > I am writing an attribute program for a roll playing game and need to roll die
- > for it.
- >
- > 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???
- >
- > Any help will be appreciated.
- >
- > Richard.
- > P2112899@csdvax.csd.unsw.edu.au
-
-
- All the RANDOM functions which accept arguments return values from ZERO to N-1,
- inclusive, where N is the argument supplied (in this case, 6). If you want a
- number from 1 to 6, then use the following:
-
- for i := 0 to 3 do pe := pe + ( random(6) + 1 );
-
- (parenthesis added for emphasis, not necessary.)
-
- If the random function you are using does return the value of 6, then use this
- instead:
-
- for i := 0 to 3 do pe := pe + ( random(5) + 1 );
-
-
- I have had this same problem myself a few times before I figured it out :)
-
- Steven Adams (INTERNET: adams@vms.ocom.okstate.edu)
-