home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!spool.mu.edu!news.nd.edu!bsu-cs!bsu-ucs.uucp!00dfmeeker
- From: 00dfmeeker@leo.bsuvc.bsu.edu (David F. Meeker)
- Newsgroups: comp.lang.pascal
- Subject: Re: help with die rolls...
- Message-ID: <1992Dec16.163958.13099@bsu-ucs>
- Date: 16 Dec 92 21:39:58 GMT
- References: <1992Dec16.170959.3637@csdvax.csd.unsw.edu.au>
- Organization: Broccoli Productions
- Lines: 38
-
- 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
-
- Well, I've never been one to trust "random" number generators,
- so here's my technique.... (Picked it up in my Basic (BLECH!) days.. ;)
- Here's a little bit of pseudo-code:
-
- Random number = int( random(100) * highest number / 100 )
-
- Use whatever number for random you think is appropriate / your
- compiler can handle... (I use 100, personally..)
-
- Anyway, hope that helps..
-
- --
- =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
- "But I know one thing that never dies: judgement on each one dead."
-
- David F. Meeker Ball State University, Muncie Indiana
- =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
- Internet: 00DFMEEKER@BSUVC.BSU.EDU
-