Great Deal! Get Instant $10 FREE in Account on First Order + 10% Cashback on Every Order Order Now

Poker simulations MATH 210-01, Fall 2021 Ryan Pellico, Department of Mathematics, Trinity College In class we saw that the function deal_hand deals a five card hand (5⇥ 2 matrix) from a shu�ed deck...

1 answer below »
Poker simulations
MATH 210-01, Fall 2021
Ryan Pellico, Department of Mathematics, Trinity College
In class we saw that the function deal_hand deals a five card hand (5⇥ 2 matrix) from a shu�ed
deck (52 ⇥ 2 matrix) of playing cards. Each row co
esponds to a card, the value in the first column
contains the rank (Ace = 1, Two = 2, . . . , Ten = 10, Jack = 11, Queen = 12, King = 13), and the value in
the second column contains the suit (Spaids = 1, Hearts = 2, Clubs = 3, Diamonds = 4). The shu�ing
is implemented by randomly permuting the deck using a for loop and the randperm function.
The hierarchy of five card poker hands is listed below. Importantly each hand is uniquely classified
as exactly one type of hand, the best hand that it meets the criteria for. See the Wikipedia link below
for a more detailed description of the poker hands.
https:
en.wikipedia.org/wiki/Poker_probability#Frequency_of_5-card_poker_hands
1. (10 points) Write the function is_pair to tell if a given input hand is one pair.
2. (10 points) Write the function is_two_pair to tell if a given input hand is two pair.
3. (10 points) Write the function is_three_of_kind to tell if a given input hand is three of a kind.
4. (20 points) Write the function is_straight to tell if a given input hand is a straight.
5. (10 points) Write the function is_full_house to tell if a given input hand is a a full house.
6. (10 points) Write the function is_four_of_kind to tell if a given input hand is four of a kind.
https:
en.wikipedia.org/wiki/Poker_probability#Frequency_of_5-card_poker_hands

function BOOL = is_pair(HAND)
% this function will return 1 is HAND is a pair, and 0 otherwise
% a pair is two cards of the same rank, and three cards of diffrent ranks
anks = HAND(:,1); % the ranks are in the first column
suits = HAND(:,2); % the suits are in the second column
% your code goes here...
end
Answered 1 days After Oct 18, 2021

Solution

Rahul answered on Oct 20 2021
121 Votes
Solution/is_four_of_kind.m
function BOOL = is_four_of_kind(HAND)
anks = HAND(:,1);
suits = HAND(:,2);
[a b]=size(ranks);
m=1;
while m y(1,m)=ranks((m+1),1)-ranks(m,1);
m=m+1;
end
if (y(1,1)==0 && y(1,2)==0 && y(1,3)==0 && y(1,4)==1)
BOOL=1;
else
BOOL=0;
end
end
Solution/is_four_of_kind.txt
function BOOL = is_four_of_kind(HAND)
anks = HAND(:,1);
suits = HAND(:,2);
[a b]=size(ranks);
m=1;
while m y(1,m)=ranks((m+1),1)-ranks(m,1);
m=m+1;
end
if (y(1,1)==0 && y(1,2)==0 && y(1,3)==0 && y(1,4)==1)
BOOL=1;
else
BOOL=0;
end
end
Solution/is_full_house.m
function BOOL = is_full_house(HAND)
anks = HAND(:,1);
suits = HAND(:,2);
[a b]=size(ranks);
m=1;
while m y(1,m)=ranks((m+1),1)-ranks(m,1);
m=m+1;
end
if (y(1,1)==0 && y(1,2)==0 && y(1,3)==1 && y(1,4)==0)
BOOL=1;
else
BOOL=0;
end
end
Solution/is_full_house.txt
function BOOL = is_full_house(HAND)
anks = HAND(:,1);
suits = HAND(:,2);
[a b]=size(ranks);
m=1;
while m y(1,m)=ranks((m+1),1)-ranks(m,1);
m=m+1;
end
if sum(y)==1
BOOL=1;
else
BOOL=0;
end
end
Solution/is_pair.m
function BOOL = is_pair(HAND)
anks = HAND(:,1);
suits = HAND(:,2);
[a...
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here