Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there an elegant way to deal with the Ace in Blackjack?

Tags:

java

blackjack

My kiddo had a homework assignment to write Blackjack in Java. I helped him a little but for the most part he did it all himself and it actually plays pretty well. He even caught an error I didn't see in how it was calculating hand values. However, there is a snag that he hasn't dealt with and every solution I can think of is really complicated and way beyond what he's going to be able to easily code up with his still rudimentary Java skills.

The Ace. In fact, not just one Ace, there's four of them and you could possibly get all four of them in a single hand. How do you elegantly deal with calculating the value of a hand of cards when there's one or more Aces, each of which might be valued at one or eleven. I feel like there should be a graceful algorithm for it, but I'm not seeing it. Of course, part of it could just be that I'm tired, but maybe you can help.

like image 639
John Munsch Avatar asked May 08 '09 02:05

John Munsch


People also ask

Can you win blackjack with an ace?

The Dealer's first ace counts as 11 unless it busts the hand. Subsequent aces count as one. If the player's total is closer to 21 than the Dealer's, the player wins even money (1 – 1).

Is an ace worth in blackjack?

An Ace will have a value of 11 unless that would give a player or the dealer a score in excess of 21; in which case, it has a value of 1. The dealer starts the game. Every player gets 2 cards, face up. The dealer gets 2 cards, with a Hole Card (1 card face down).

Is an ace worth 1 or 11 in blackjack?

Face cards each count as 10, Aces count as 1 or 11, all others count at face value. An Ace with any 10, Jack, Queen, or King is a “Blackjack.” If you have a Blackjack, the dealer pays you one-and-a-half times your bet — unless the dealer also has a Blackjack, in which case it's a “push” and neither wins.

What if the dealer has an ace?

If the dealer has an ace, and counting it as 11 would bring the total to 17 or more (but not over 21), the dealer must count the ace as 11 and stand. The dealer's decisions, then, are automatic on all plays, whereas the player always has the option of taking one or more cards.


1 Answers

Just treat each ace as 11. Then while the value is over 21, subtract 10 from your total for each ace in your hand.

like image 182
Unknown Avatar answered Nov 10 '22 17:11

Unknown