I have below outlined the different probabilities for different poker hands given
5 cards from a 52 cards deck. The frequencies are from wikipedia
http://en.wikipedia.org/wiki/Poker_probability




These frequencies are quite interesting....I wonder if they found them by "brute fource"
ie just list all permutations and start counting.

Let say you are given 3 cards. What is the probability that you will for example get a
"Royal flush" given these 3 known cards and two additional unknown cards.

First I thought the probability depend on what types of cards you are holding.
However, on second thought I realized that that is actually a gamblers fallacy
since the cards are dealt randomly your current holdings should not matter.

It would be interesting to set up a poker simulation in MapleSim since it appears to be less
difficult analyze the problem that way.

restart:
randomize():
with(combinat):
with(ListTools):

Clubs := [C[A], C[K], C[Q], C[J], seq(C[i], i = 2 .. 10)]:
Diamonds := [D[A], D[K], D[Q], D[J], seq(D[i], i = 2 .. 10)]:
Hearts := [H[A], H[K], H[Q], H[J], seq(H[i], i = 2 .. 10)]:
Spades := [S[A], S[K], S[Q], S[J], seq(S[i], i = 2 .. 10)]:

Cards := [op(Clubs), op(Diamonds), op(Hearts), op(Spades)]:
Deal := randcomb(Cards, 3);


Let say you have three players. I think the difficulitty lies in determining what hand is
"sufficient" in order to not fold. You have to factor in that the cards
you are holding will give a zero probability that your opponents are holding
exactly the same cards which means that your opponents probabilities for all
the different hands will be different from your probabilities

I might be wrong here, but this is just from the top of my head.

The hand detection might also be tricky. For example:

number := [K, K, Q, 3, 6, 10, 10]:
suit := [C, C, D, C, D, C, K]:

# Royal Flush - An Ace-High straight of one suit.
if verify(convert([A, K, Q, J, 10], set), convert(number, set), `subset`) = true then
if suit[Search(A, number)] = suit[Search(K, number)] and suit[Search(K, number)] = suit[Search(Q, number)] and suit[Search(Q, number)] = suit[Search(J, number)] and suit[Search(J, number)] = suit[Search(10, number)] then print(10) end if
end if:

# Straight Flush - A straight of entirely one suit.
cc := subs({A = 13, J = 10, K = 12, Q = 11}, number):
if `and`(max([Occurrences(C, suit), Occurrences(D, suit), Occurrences(H, suit), Occurrences(S, suit)]) >= 5, Occurrences(max(cc))) then print(9) end if:

# Four of a Kind
if max([seq(Occurrences(op(Clubs[x]), number), x = 1 .. 13)]) = 4 then print(8) end if;


I have attached the maple worksheets with the code  Poker-Maple.mw
This project is far from finished but it would be nice to start a discussion about its implimentations.


Please Wait...