Advertisement

blackjack

Started by September 25, 2024 07:27 PM
34 comments, last by pbivens67 2 months ago

I am trying to find a blackjack table sprite in bmp format, can somebody help please

I fround one thx

Advertisement

I am working on a blackjack game, I want to draw a card from the deck and then draw a nonduplicate card form the deck, I am using the random number generator int num=rand()%56+1 function to draw random cards from the deck. let me know if you need any code. I am using 56 cards because the ACE can be one or eleven.

By adding a second ACE in the deck you are changing the odds of the game. A player has a higher chance to draw an ACE from your deck (2 out of 13, instead of 1 out of 13 in a normal deck).

That doesn't seem right to me.

The choice of 1 or 11 for an ACE has nothing to do with the deck. It's the player that decides that.

I am still stuck on how to draw a second nonduplicate from the deck

pbivens67 said:
I am still stuck on how to draw a second nonduplicate from the deck

That's easy.

Draw a second card. If it is a duplicate put it back and try again. If it is not a duplicate, you're done.

You may want to limit the number of tries there, or you may be drawing and putting back cards forever if the deck only has duplicate cards left.

Advertisement

what function should I use to accomplish this

// Draw a card from the deck that is different from the previousCard. Use -1 for the previousCard
// if all cards are allowed.
int drawCard(int previousCard) {
    // Repeatedly draw a card until you don't have a card that is equal to previousCard.
    
    return drawnCard;
}

You may want to have a look at the “while” statement.

You can also use a vector of cards.

This topic is closed to new replies.

Advertisement