Question: Write a program(with Java) that maximizes earning from blackjack game where the deck is known. The rules are: -The goal of blackjack is to beat
Write a program(with Java) that maximizes earning from blackjack game where the deck is known.
The rules are:
-The goal of blackjack is to beat the dealer's hand without going over 21.
-Face cards are worth 10. Aces are worth 1 or 11, whichever makes a better hand.
-Each player starts with two cards, one of the dealer's cards is hidden until the end.
-You can only double/split on the first move, or first move of a hand created by a split.
-You cannot play on two aces after they are split.
-To 'Hit' is to ask for another card. To 'Stand' is to hold your total and end your turn.
-If you go over 21 you bust, and the dealer wins regardless of the dealer's hand.
-If you are dealt 21 from the start (Ace & 10), you got a blackjack.
-Blackjack usually means you win 1.5 the amount of your bet. Depends on the casino.
-Dealer will hit until his/her cards total 17 or higher.
-Doubling is like a hit, only the bet is doubled, and you only get one more card.
-Split can be done when you have two of the same card - the pair is split into two hands.
-Splitting also doubles the bet, because each new hand is worth the original bet.
-You can only double/split on the first move, or first move of a hand created by a split.
-You cannot play on two aces after they are split.
-You can double on a hand resulting from a split, tripling or quadrupling you bet.
.-The deck should be represented as an integer array. The length of the array must be 52 and the array holds integers from 0 to 51. This is the general form.

Each integer represents a different playing card.Your program should allow users to enter their sequence of deck in the form of 0, 1, , 1 For example: a user can enter 5,4,11,29,39,45, to the program.
BJ(i): if n-i 21: (bust) options.append(-1(bust) + BJ(i +p+2)) break for d in range(2,n-i-p) dealer = sum(C1+1, C1+3, Ci+p+2:i+p+d) if dealer > 17: break if dealer > 21: dealer =0 (bust) options.append(cmp(player, dealer) + BJ(i+p+d)) return max(options) BJ(i): if n-i 21: (bust) options.append(-1(bust) + BJ(i +p+2)) break for d in range(2,n-i-p) dealer = sum(C1+1, C1+3, Ci+p+2:i+p+d) if dealer > 17: break if dealer > 21: dealer =0 (bust) options.append(cmp(player, dealer) + BJ(i+p+d)) return max(options)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
