Draw a 7 cards out of a deck. Some cards have special properties. What are my odds of grabbing 6 specific cards on the first draw of 7 cards?

3 views (last 30 days)
There 60 colored cards in a deck, within that deck there are 29 different colors of cards, meaning there are more than 1 of some the cards. I will write the amount of each colored card below. Some cards have special properties that allow you to draw several more cards if drawn or find a specific card with in the deck. If I were to shuffle the cards and to draw 7 cards, what are my odds of drawing a lime, amber, aqua, blue, and 2 green cards? How can I answer this in MATLAB?
  • 1 Blonde
  • 1 Snow
  • 2 White
  • 2 Grey
  • 1 Silver *shuffle your hand into the deck, then flip a coin, if heads draw 7 cards, if tails draw 4 cards
  • 1 Charcoal
  • 3 Pink *discard your hand, then draw 7 cards.
  • 1 Rose *search your deck for up to 2 green or 2 purple cards or 1 green and 1 purple card, then shuffle your deck
  • 2 Folly
  • 1 Red
  • 1 Ruby
  • 2 Rust
  • 4 Brown *discard 2 cards from your hand, then search the deck for either an amber, aqua, or blue card, then shuffle the deck
  • 3 Tan *look at the top 4 cards of the deck, if you find a silver, pink, rose, brown, orange, lime card there you may put it into your hand, then shuffle the deck
  • 3 Wheat
  • 1 Orange * search your deck for a silver, pink, rose, brown, orange, lime card and put it into your hand, then shuffle the deck
  • 2 Gold
  • 4 Amber
  • 2 Yellow
  • 3 Mustard
  • 6 Green
  • 3 Lime
  • 1 Teal
  • 2 Cyan
  • 2 Aqua
  • 2 Blue
  • 1 Cobalt
  • 2 Violet
  • 1 Purple
  5 Comments
Alex Simmons
Alex Simmons on 17 Nov 2015
all special conditions are optional, you do not have to invoke them if you do not wish to. if a situation like that happens, the code would run variation of choosing to invoke the condition and another would choose not to. which ever one got closer to the goal, would be the one that the code would proceed with.
Walter Roberson
Walter Roberson on 17 Nov 2015
When you run a Monte Carlo simulation and there is a choice of actions, you would normally choose one of the actions randomly and proceed with it.
If you instead run all of the actions simultaneously and one or more of the actions involve probability (dealing new cards) then you need to merge the probabilities associated with all of the possibilities in order to get an overall probability. But in order to do that, you need to know how to weight the various branches. Because a person "playing the game" would not be able to select all of the actions simultaneously, you would normally weight the branches by the conditional probability that the person selected the branch. And if you are going to do that then you might as well just select one branch at random and "play it out" rather than running all of the branches simultaneously.
You need to decide whether you are doing a Monte Carlo simulation, in which case you need to choose possibilities randomly, or if you are exploring the entire state space of all of the possible games to find the absolute probability of winning, or if you are doing something like an Alpha-Beta pruning to try to find winning strategies (like you would if you were exploring a chess or checkers game.)

Sign in to comment.

Answers (3)

Image Analyst
Image Analyst on 17 Nov 2015
You can assign certain ID numbers to the cards, like gold cards are card 1 & 2, and amber cards are 3,4,5 & 6, and so on for the other colors. Then use randperm to shuffle, and then use indexing to deal cards from the deck. It's not too hard. See my attached demos.
Sounds like homework, so I think my demos are help enough. If it's homework, you're supposed to attach a tag of "homework" to your post.
  3 Comments
Alex Simmons
Alex Simmons on 22 Nov 2015
Edited: Walter Roberson on 22 Nov 2015
clc; clear;
%Deck
deck={'blonde' 'snow' 'white' 'white' 'grey' 'grey' 'silver' 'charcoal' 'pink' 'pink' 'pink' 'rose' 'folly' 'folly' 'red' 'ruby' 'rust' 'rust' 'brown' 'brown' 'brown' 'brown' 'tan' 'tan' 'tan' 'wheat' 'wheat' 'wheat' 'orange' 'gold' 'gold' 'amber' 'amber' 'amber' 'amber' 'yellow' 'yellow' 'mustard' 'mustard' 'mustard' 'green' 'green' 'green' 'green' 'green' 'green' 'lime' 'lime' 'lime' 'teal' 'cyan' 'cyan' 'aqua' 'aqua' 'blue' 'blue' 'cobalt' 'violet' 'violet' 'purple'};
%Hand
hand=randsample(deck,7,false)

this is what i got so far, how do check my hand, to see if any of the cards have a special condition, and use or not use the special condition?

Sign in to comment.


Walter Roberson
Walter Roberson on 22 Nov 2015
Edited: Walter Roberson on 22 Nov 2015
cards = {'blonde', 1;
'snow', 1;
'white', 2;
'grey', 2;
'silver', 1;
'charcoal', 1;
'pink', 3;
'rose', 1;
'folly', 2;
'red', 1;
'ruby', 1;
'rust', 2;
'brown', 4;
'tan', 3;
'wheat', 3;
'orange', 1;
'gold', 2;
'amber', 4;
'yellow', 2;
'mustard', 3;
'green', 6;
'lime', 3;
'teal', 1;
'cyan', 2;
'aqua', 2;
'blue', 2;
'cobalt', 1;
'violet', 2;
'purple', 1};
special_cards = {'silver', 'pink', 'rose', 'brown', 'tan', 'orange'}
numcolor = size(cards,1);
cards = [cards, repmat({false}, numcolor, 1)];
[~, idx] = ismember(special_cards, cards(:,1) );
cards(idx,3) = {true};
At this point, cards is a cell array whose first column is a color, second column is a repeat count, and third column is true if the color is special.
card_idx = [];
for K = 1 : numcolor
card_idx = [card_idx, repmat(K, 1, cards{K,2})];
end
name_this_card = @(idx) [cards{card_idx(idx),1}, repmat('*',1,cards{card_idx(idx),3})]
name_cards = @(card_id_list) arrayfun(name_this_card, card_id_list, 'Uniform', 0);
Now card_idx is a "population" of cards that can be sampled from, with the result indicating which row of "cards" the card corresponds to. name_this_card is a helper function and name_cards is a function to name the cards in a list.
To draw cards:
num_cards_in_deck = length(card_idx);
deck_discards = [];
deck_remaining = randperm(num_cards_in_deck);
cards_in_hand = [];
then
num_to_draw = 7; %this time
cards_drawn = deck_remaining(1:num_to_draw);
deck_remaining = deck_remaining(num_to_draw+1:end);
cards_in_hand = [cards_in_hand, cards_drawn];
named_hand = name_cards(cards_in_hand);
fprintf('You now have:');
fprintf(' %s', named_hand{:});
fprintf('\n');
  2 Comments
Alex Simmons
Alex Simmons on 23 Nov 2015
this is cool. working on if then statements to see if there are any special cards in the hand, and how to use them if need be. will post my results soon.
Walter Roberson
Walter Roberson on 23 Nov 2015
which_are_special = [cards{card_idx(cards_in_hand),3}];
Now it is a logical vector of whether each card in the hand is special.
(Did you notice that I put a '*' beside the names of the cards that are special in the hand printout? )

Sign in to comment.


Alex Simmons
Alex Simmons on 9 Dec 2015
well i was thinking along the lines of something like spc_pink=strfind(named_hand,'pink*'); which returns logical values in a array if true. then use the logical value to execute the special condition. for instance if pink is drawn the player has the option to discard the hand and redraw 7 new cards.
  4 Comments
Walter Roberson
Walter Roberson on 10 Dec 2015
discard_which = [1 4 5]; %for example
cards_being_discarded = cards_in_hand(discard_which);
cards_in_hand(discard_which) = [];
discard_deck = [discard_deck, cards_being_discarded];

Sign in to comment.

Categories

Find more on Signal Processing in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!