Multiple Combinations


Closed Thread
Results 1 to 3 of 3
  1. #1
    Join Date
    Apr 2011
    Posts
    2

    Default Multiple Combinations

    I'm making a yahtzee game and trying to determine when someone has a three-of-a-kind, four-of-a-kind, full house, small straight, large straight, and yahtzee. The yahtzee part is easy since all five of the numbers are the same, but the others aren't so easy. Is there a better way to determine when I have three-of-a-kind than using a ton of IF THENS to check all possible ways of getting three of the same numbers?

  2. #2
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,605


    Did you find this post helpful? Yes | No

    Default Re: Multiple Combinations

    Code:
    Dice VAR BYTE[5]    'Array of 5 bytes, one for each dice.
    Results VAR BYTE[6]  'Array of six bytes containing the number of ones, twos, threes etc
    i VAR BYTE
    
    For i = 0 to 5
      Results[i] = 0   'Clear counters
    Next
    
    For i = 0 to 4     'Itterate thru the five dices
      Select Case Dice[i]
        Case 1
          Results[0] = Results[0] + 1   'Ones
        Case 2
          Results[1] = Results[1] + 1   'Twos
        Case 3
          Results[2] = Results[2] + 1   'Threes
        Case 4
          Results[3] = Results[3] + 1   'Fours
        Case 5
          Results[4] = Results[4] + 1   'Fives
        Case 6
          Results[5] = Results[5] + 1   'Sixes
      End Select
    NEXT
    Now you know how MANY of each you've got, perhaps that's a start?

  3. #3
    Join Date
    Apr 2011
    Posts
    2


    Did you find this post helpful? Yes | No

    Default Re: Multiple Combinations

    Quote Originally Posted by HenrikOlsson View Post
    Code:
    Dice VAR BYTE[5]    'Array of 5 bytes, one for each dice.
    Results VAR BYTE[6]  'Array of six bytes containing the number of ones, twos, threes etc
    i VAR BYTE
    
    For i = 0 to 5
      Results[i] = 0   'Clear counters
    Next
    
    For i = 0 to 4     'Itterate thru the five dices
      Select Case Dice[i]
        Case 1
          Results[0] = Results[0] + 1   'Ones
        Case 2
          Results[1] = Results[1] + 1   'Twos
        Case 3
          Results[2] = Results[2] + 1   'Threes
        Case 4
          Results[3] = Results[3] + 1   'Fours
        Case 5
          Results[4] = Results[4] + 1   'Fives
        Case 6
          Results[5] = Results[5] + 1   'Sixes
      End Select
    NEXT
    Now you know how MANY of each you've got, perhaps that's a start?
    This actually worked out really well, I got it checking for each one. Thanks for your help!

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts