35 points In this problem we study the popular card game Bla

[35 points] In this problem, we study the popular card game Blackjack, also known as twenty- one. In our simplfied and modified version of the game, the dealer draws cards from an infinite number of well-shuffled decks of 52 cards. Therefore, the probability of getting each of the 13 ranks ( Ace, 2, 3, , 10, Jack, Queen, King) in each drawing is simply Note the suits (spades, hearts, diamonds, and clubs) do not matter for this game. When the game starts, both you and the dealer will get two cards. While both your cards are face-up, only the first card of the dealer is revealed and her/his second card faces down. After receiving your first two cards, you next choose to \"hit\" (take a third card and end your turn) or \"stand\" (do not take a third card and end your turn). There is no double or split for our version of the game The dealer will do the same after you. Both you and the dealer will get at most three cards. (In a real game, the player and the dealer can take multiple turns to hit or stand). You and the dealer get points by adding together the values of your cards. Face cards (Kings, Queens and Jacks) are counted as ten points. Ace is always counted as 11 points (which is different from the usual twenty-one). All other cards are counted as the numeric value shown on the I. Your objective is to beat the dealer in one of the following ways: . Get 21 points on your first two cards (called a \"blackjack\"); . Let the dealer\'s points exceed 21 (called \"bust\") before you do; or » Reach a final score strictly higher than the dealer without bust

Solution

Code when player chooses Hit :

count = 0;
for a = 0:1000000
   x1 = randi([1,13]);
   y1 = randi([1,13]);
   x2 = randi([1,13]);
   y2 = randi([1,13]);
   if x1 > 10
       x1 = 10;
   elseif x1 == 1
       x1 = 11;
   end
   if x2 > 10
       x2 = 10;
   elseif x2 == 1
       x2 = 11;
   end
   if y1 > 10
       y1 = 10;
   elseif y1 == 1
       y1 = 11;
   end
   if y2 > 10
       y2 = 10;
   elseif y2 == 1
       y2 = 11;
   end
   sumx = x1 + x2;
   sumy = y1 + y2;

   x3 = randi([1,13]);
   if x3 > 10
       x3 = 10;
   elseif x3 == 1
       x3 = 11;
   end
   sumx = sumx + x3;
   if sumy < 17
       y3 = randi([1,13]);
       if y3 > 10
           y3 = 10;
       elseif y3 == 1
           y3 = 11;
       end
       sumy = sumy + y3;
   end
   if sumx > sumy && sumx <= 21
       count = count+1;
   elseif sumx <= 21 && sumy > 21
       count = count+1;
   end
end
p = count/1000000;
fprintf (\"Hit : %f\ \",p)

Output :

Hit : 0.235810

Code when Player chooses to Stand :

count = 0;
for a = 0:1000000
   x1 = randi([1,13]);
   y1 = randi([1,13]);
   x2 = randi([1,13]);
   y2 = randi([1,13]);
   if x1 > 10
       x1 = 10;
   elseif x1 == 1
       x1 = 11;
   end
   if x2 > 10
       x2 = 10;
   elseif x2 == 1
       x2 = 11;
   end
   if y1 > 10
       y1 = 10;
   elseif y1 == 1
       y1 = 11;
   end
   if y2 > 10
       y2 = 10;
   elseif y2 == 1
       y2 = 11;
   end
   sumx = x1 + x2;
   sumy = y1 + y2;

   if sumy < 17
       y3 = randi([1,13]);
       if y3 > 10
           y3 = 10;
       elseif y3 == 1
           y3 = 11;
       end
       sumy = sumy + y3;
   end
   if sumx > sumy && sumx <= 21
       count = count+1;
   elseif sumx <= 21 && sumy > 21
       count = count+1;
   end
end
p = count/1000000;
fprintf (\"Stand : %f\ \",p)

Output :

Stand : 0.404600

Based on the previous two estimates, the player should choose to Stand because the probabilityof winning is greater when choose to stand compared to when he choose to Hit.

 [35 points] In this problem, we study the popular card game Blackjack, also known as twenty- one. In our simplfied and modified version of the game, the dealer
 [35 points] In this problem, we study the popular card game Blackjack, also known as twenty- one. In our simplfied and modified version of the game, the dealer
 [35 points] In this problem, we study the popular card game Blackjack, also known as twenty- one. In our simplfied and modified version of the game, the dealer

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site