home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.pascal
- Path: sparky!uunet!cs.utexas.edu!milano!cactus.org!vlaurent
- From: vlaurent@cactus.org (Vince Laurent)
- Subject: Dice Rolling Poser
- Message-ID: <1992Jul28.170603.22091@cactus.org>
- Organization: Capital Area Central Texas UNIX Society, Austin, Tx
- Date: Tue, 28 Jul 1992 17:06:03 GMT
- Lines: 49
-
- I am trying to figure out some dice algorithms and am stumped. Here
- is a sample of what I am trying to do, though I would like to be
- able to do it for any multiple of dice. I will do my example with
- 6 dice:
-
- You roll 6 dice and are alowed to sort them from highest to lowest.
- The idea is to get the longest straight possible. For example:
-
- 1 2 3 4 5 6 = six in a row note that the x's are numbers which can
- 1 2 3 4 5 x = five in a row NOT come up from an earlier straight.
- x 2 3 4 5 6 = five in a row For example, the x in the 5 in a row
- 1 2 3 4 x x = four in a row first one) can not be a 6 else it would
- x 2 3 4 5 x = four in a row be a straight of length 6. Also, there
- x x 3 4 5 6 = four in a row can be multiple straights. For example,
- 1 2 3 x x x = three in a row a straight of length 4 and a straight
- x 2 3 4 x x = three in a row of length 2 can co-exist as well as 3
- x x 3 4 5 x = three in a row straights of length 2 (eg: 121212).
- x x x 4 5 6 = three in a row
- 1 2 x x x x = two in a row
- x 2 3 x x x = two in a row
- x x 3 4 x x = two in a row
- x x x 4 5 x = two in a row
- x x x x 5 6 = two in a row
-
- The question is: how many combinations of 6 in a row are there? 5 in
- a row? and so on. Remember, a roll of 123411 is a straight of length
- 4 and therefore can not be counted in anything else (eg: straight of
- length three 123xxx or x234xxx or straights of length two). Also, I
- am trying to keep this generic so if someone uses 4-4sided dice or 6-
- 6 sided dice, and so on.
-
- I have managed to write a program that rolls 6 dice and then sorts them
- but I cna't figure out an algorithm to count what I am looking for.
-
- Any help would be GREATLY appreciated. NO - THIS IS NOT FOR CLASS, I
- am working on a board game!
-
- Vince Laurent
- | FidoNet 1:382/10 | vlaurnet@cactus.org | RimeNet->MAH |
-
- p.s. I posted it here because I do most of programming in pascal and would
- like to get some code to do this for me.
-
-
- --
- Vince Laurent
- Internet vlaurent@cactus.org
- Connect America BBS 1:382/10
-
-