Write a program for the relation
better-poker-hand(Hand1,Hand2,Hand) that succeeds if
Hand is the better poker hand between Hand1 and
Hand2 (for your purposes, just imagine that the function
computes Hand). For those unfamiliar with poker, here are some
rules necessary for answering this excercise.
-
The order of cards is 2, 3, 4, 5, 6, 7, 8, 9, 10, Jack,
Queen, King, Ace.
-
Each hand consists of five cards.
-
The rank of the hands in ascending order is no pairs <
one pair < two pairs < three of a kind < flush < straight <
full house < four of a kind < straight flush.
- Where two cards have the same rank, the higher denomination
wins, for example, a pair of kings beats a pair of 7's.
Hints: (1) Represent a poker hand by a list of terms of the
form card(Suit, Value). For example, a hand consisting of
the Ace of Spades and the nine of Clubs would be represented
by the list [card(spades,ace),card(clubs,9)]. (2) It may
be helpful to define relations such as has_flush(Hand),
which is true if all of the cards in Hand are of the same
suit. (3). The number of cases to consider is reduced
if the hand is first sorted.