home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #16 / NN_1992_16.iso / spool / comp / lang / pascal / 4585 < prev    next >
Encoding:
Text File  |  1992-07-28  |  2.3 KB  |  59 lines

  1. Newsgroups: comp.lang.pascal
  2. Path: sparky!uunet!cs.utexas.edu!milano!cactus.org!vlaurent
  3. From: vlaurent@cactus.org (Vince Laurent)
  4. Subject: Dice Rolling Poser
  5. Message-ID: <1992Jul28.170603.22091@cactus.org>
  6. Organization: Capital Area Central Texas UNIX Society, Austin, Tx
  7. Date: Tue, 28 Jul 1992 17:06:03 GMT
  8. Lines: 49
  9.  
  10. I am trying to figure out some dice algorithms and am stumped. Here
  11. is a sample of what I am trying to do, though I would like to be
  12. able to do it for any multiple of dice. I will do my example with
  13. 6 dice:
  14.  
  15. You roll 6 dice and are alowed to sort them from highest to lowest.
  16. The idea is to get the longest straight possible.  For example:
  17.  
  18. 1 2 3 4 5 6 = six in a row    note that the x's are numbers which can
  19. 1 2 3 4 5 x = five in a row   NOT come up from an earlier straight.
  20. x 2 3 4 5 6 = five in a row   For example, the x in the 5 in a row
  21. 1 2 3 4 x x = four in a row   first one) can not be a 6 else it would
  22. x 2 3 4 5 x = four in a row   be a straight of length 6.  Also, there
  23. x x 3 4 5 6 = four in a row   can be multiple straights. For example,
  24. 1 2 3 x x x = three in a row  a straight of length 4 and a straight
  25. x 2 3 4 x x = three in a row  of length 2 can co-exist as well as 3
  26. x x 3 4 5 x = three in a row  straights of length 2 (eg: 121212).
  27. x x x 4 5 6 = three in a row
  28. 1 2 x x x x = two in a row
  29. x 2 3 x x x = two in a row
  30. x x 3 4 x x = two in a row
  31. x x x 4 5 x = two in a row
  32. x x x x 5 6 = two in a row
  33.  
  34. The question is: how many combinations of 6 in a row are there? 5 in
  35. a row? and so on.  Remember, a roll of 123411 is a straight of length
  36. 4 and therefore can not be counted in anything else (eg: straight of
  37. length three 123xxx or x234xxx or straights of length two). Also, I
  38. am trying to keep this generic so if someone uses 4-4sided dice or 6-
  39. 6 sided dice, and so on.
  40.  
  41. I have managed to write a program that rolls 6 dice and then sorts them
  42. but I cna't figure out an algorithm to count what I am looking for.
  43.  
  44. Any help would be GREATLY appreciated.  NO - THIS IS NOT FOR CLASS, I
  45. am working on a board game!
  46.  
  47. Vince Laurent
  48. | FidoNet 1:382/10 | vlaurnet@cactus.org | RimeNet->MAH |
  49.  
  50. p.s. I posted it here because I do most of programming in pascal and would
  51. like to get some code to do this for me.
  52.  
  53.  
  54. -- 
  55. Vince Laurent 
  56. Internet  vlaurent@cactus.org
  57. Connect America BBS 1:382/10
  58.  
  59.