Results 1 to 5 of 5

Thread: Scoring?

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Mar 2005
    Posts
    71

    Unhappy Scoring?

    Hey there, just asking how I could implement a scoring system to add up the totals of the player and dealer to see who has the highest number for a game of blackjack. Currently not started on the computer controlled dealer but just wondering how I woul add the total value of the cards together while using cards.dll

    VB Code:
    1. Private Sub Form_Load()
    2. Randomize
    3. End Sub
    4. Private Sub CMD_Deal_Click()
    5. cdtDraw Me.hdc, 370, 75, Int((51 - 0 + 1) * Rnd + 0), 0, vbWhite
    6. cdtDraw Me.hdc, 300, 75, Int((51 - 0 + 1) * Rnd + 0), 0, vbWhite
    7. cdtDraw Me.hdc, 370, 300, Int((51 - 0 + 1) * Rnd + 0), 0, vbWhite
    8. cdtDraw Me.hdc, 300, 300, Int((51 - 0 + 1) * Rnd + 0), 0, vbWhite
    9.  
    10.  
    11. End Sub
    12.  
    13. Private Sub CMD_Hit_Click()
    14. Static Xpos As Long
    15. If Xpos = 0 Then
    16. Xpos = 300
    17. Else: Xpos = Xpos + 25
    18. End If
    19.  
    20. cdtDraw Me.hdc, Xpos, 300, Int((51 - 0 + 1) * Rnd + 0), 0, vbWhite
    21.  
    22. End Sub
    23.  
    24.  
    25. Private Sub CMD_Main_Menu_Click()
    26. MainMenu.Show
    27. Unload Me
    28. End Sub

    IT got me stumped and also to recalculate the total after each time the hit command is pressed

    Any help is appreciated

  2. #2

    Thread Starter
    Lively Member
    Join Date
    Mar 2005
    Posts
    71

    Re: Scoring?

    Iv added in some value but I believe that my calculation is way off and I just cant seem to get my head around it.
    Im wanting it to add the two random cards dealt to the player from the deck so that
    player total = random card 1 + random card 2

    and then to add on to this each time I click the hit command

    player total = player total + random card 3

    VB Code:
    1. Private Sub Form_Load()
    2. Randomize
    3. Dim Player1_total(0 To 1) As Integer
    4. Dim Dealer_total(0 To 1) As Integer
    5.  
    6. End Sub
    7. Private Sub CMD_Deal_Click()
    8. cdtDraw Me.hdc, 370, 75, Int((51 - 0 + 1) * Rnd + 0), 0, vbWhite
    9. cdtDraw Me.hdc, 300, 75, Int((51 - 0 + 1) * Rnd + 0), 0, vbWhite
    10. cdtDraw Me.hdc, 370, 300, Int((51 - 0 + 1) * Rnd + 0), 0, vbWhite
    11. cdtDraw Me.hdc, 300, 300, Int((51 - 0 + 1) * Rnd + 0), 0, vbWhite
    12.  
    13. Player1_total = Int((51 - 0 + 1) * Rnd + 0) + Int((51 - 0 + 1) * Rnd + 0)
    14. Dealer_total = Int((51 - 0 + 1) * Rnd + 0) + Int((51 - 0 + 1) * Rnd + 0)
    15.  
    16.  
    17. End Sub
    18.  
    19. Private Sub CMD_Hit_Click()
    20. Static Xpos As Long
    21. If Xpos = 0 Then
    22. Xpos = 450
    23. Else: Xpos = Xpos + 25
    24. End If
    25.  
    26. cdtDraw Me.hdc, Xpos, 300, Int((51 - 0 + 1) * Rnd + 0), 0, vbWhite
    27. Player1_total = Player1_total +
    28. If Player1_total > 21 Then
    29. MsgBox "You are bust would you like another game?"
    30.  
    31. End If
    32.  
    33.  
    34. End Sub
    35.  
    36.  
    37. Private Sub CMD_Main_Menu_Click()
    38. MainMenu.Show
    39. Unload Me
    40. End Sub

  3. #3
    Fanatic Member Comintern's Avatar
    Join Date
    Nov 2004
    Location
    Lincoln, NE
    Posts
    826

    Re: Scoring?

    Last card game I did, I indexed the cards to allow easy comparison and value manipulations. The system I used was that a card's index was the number of the card, ie. 1 = Duece, 13 = Ace, multiplied by ten, plus the number of the suit (according to precidence.) So, assuming the precidence of suits was Spades - Hearts - Diamonds - Clubs, the 2 of Clubs would be 11, the King of Hearts would be 123, the Ace of Spaces would be 134, etc. That let me do direct comparisons for value based on the index of the card, either including suit precedence or not. To compare (or add) a value, just take the integer of the card index divided by 10 for 'suitless' comparisons, and the index itself for 'suited' comparisons. I actually used numeric representations of the cards in code, and when drawing them or naming them just called a translation function. I'm not familiar with cards.dll so I don't know how it functions, but it appears that it is just displaying cards for you, and it would be up to you to keep track of the values. Hope this helped more than it confused.

  4. #4

    Thread Starter
    Lively Member
    Join Date
    Mar 2005
    Posts
    71

    Re: Scoring?

    So i need to give each cards its own number?. Im not to sure how to go about doing this and what the calculation would involve. If i could add and index value to the cards I could figure it out easy enough. Does anyone know how I would index the cards or will I have to create a whole new array and come up with the image files myself?

  5. #5

Posting Permissions

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



Click Here to Expand Forum to Full Width