[Solved] CECS 552 Programming Assignment 2

Click And Check all our Assignments
Click Here and Upload you Assignment for Free!


100/100 Trustscore on scamadviser.com

10 USD $

Category: Tag:

Monte Carlo Simulation for Playing Blackjack

A simple version of the (two-player) game of Blackjack is described as follows. For this version we use four special decks of cards in which each deck, in addition to its usual cards, has an additional four cards, each with a numerical value equal to 1. The four decks of cards are randomly shuffled together to make a dealing deck of 56 × 4 = 224 cards total. The value of a number card equals the card number, the value of a face card equals 10, while the value of an ace equals 11 (aces no longer can equal 1, since we’ve added the 1 cards). In what follows we let random variable X represent the result of drawing a card at random from the (entire) dealing deck. For example, P(X = i) = 16/224 = 1/14, for all i = 1,…,9,11}, while P(X = 10) = 64/224 = 2/7.

Each player is first dealt a card facing downward that is hidden from her opponent. Players are then alternately dealt cards facing upward that are visible to the opponent. Before a card is dealt to a player, she has the option of holding, meaning that she is not dealt any further cards. If she does not hold, then she hits, meaning that she is dealt an additional card. Play ends when one of the following has occurred:

  1. a player hits, and the card dealt to her results in a sum (of the values of all her cards) equal to 21, in which case she immediately wins the game;
  2. a player hits, and the card dealt to her results in a sum that exceeds 21, in which case she immediately loses the game; or
  3. both players have decided to hold, in which case the winner is the player whose card values have the highest sum (a tie occurs if the sums are equal).

When a game ends, all dealt cards are revealed to both players, and the cards are placed in the used pile, and are never dealt again during the match, which is a sequence of games that ends once the


dealing deck is exhausted (if this happens during a game, then the game ends in a tie). Note that, during a match, the players take turns at being dealt the first card.

Now consider the following strategy that can be used by a player in order to decide on whether to hit or hold on a given turn. In this strategy, player P hits provided one of the following is true. Let S denote the sum of P’s cards.

  1. P’s opponent has not yet decided to hold, and P(X + S ≤ 21) > p1, where p1 ≥ 0.5 is some threshold value that is provided as input by the user. Here X represents the value of the next card that will be dealt if P decides to hit. The reasoning is that P hits provided there is sufficient probability that the next card dealt will not bring her sum over 21.
  2. P’s opponent has already decided to hold, and E[X|X +Sv < 21]+Sv > S. Here, X represents the opponent’s hidden card. In words, P calculates the expected value of the hidden card, on condition that, when adding it to the visitble sum, it must give a value that is less than 21. Then, if this expected value is added to the visible sum, and it exceeds S, then P hits because she believes that her opponent has held with a better hand.
  3. P’s opponent has already decided to hold, and P(X + S ≤ 21) ≥ p2, where p2 ≥ 0.5 is a threshold value provided as input by the user. In this case, P hits because she has a good chance of not going over 21. Of course, how “good” depends on the value of p2.

Program Options

  1. The user inputs a value S, and the program returns P(X + S ≤ 21).
  2. The user inputs a value Sv, and the program returns E[X|X + Sv < 21].
  3. The user inputs a value M, that represents the number of matches to be played between two players. Then the user inputs a (p1,p2) pair for each of the players. The program simulate M matches between these two players and reports on the followng: i) the number of games won by each player over all the matches, and ii) a 90% confidence intervals for each player that captures her probability of winning against her opponent.
  4. Repeat the previous option, but now, for each player, indicate if the player is either assuming X is sampled over the original deck, or if X is being sampled over the remaining In other words, in addition to p1 and p2 indicate whether or not the player is “card counting”, meaning she is memorizing the cards that have already been played.



There are no reviews yet.

Only logged in customers who have purchased this product may leave a review.

Shopping Cart
[Solved] CECS 552 Programming Assignment 2
10 USD $