[Purdue-pm] more about "xoker" hands challenge

Mark Senn mark at ecn.purdue.edu
Sun Apr 10 12:52:35 PDT 2011


On 2011-04-09 Joe Kline suggested changing the card rank "10" to "t"
so all card ranks would be one character.  So,
    10c 8d ah 2s kd / 10s as ad 2h jd 7d
    tc 8d ah 2s kd / 10s as ad 2h jd 7d

There are 15,820,024,220 ways to choose 10 cards from 52 cards.  Because
of that I wanted to fnd a more compact representation of hands.  I made
the following improvements (continuing from above)

    tc 8d ah 2s kd 10s as ad 2h jd 7d

Finally, I wanted to compress each card representation from two bytes to
one byte.  To do that I gave each rank a number 0--12 and each suit a
number 0--3.  I wanted each card representation to be a printable character
so one could see it easily and so it would not be confused with  newline
character.  I did that using the
    chr((1 << 6) | ($nrank << 2) | ($nsuit))
expression below.

Below is the program I'm running to produce all the possible combinations.
It has produced only about 5% of the output so far.

===== program starts with next line

#  revised 'enumerate.pl  2011-04-10  Mark Senn  http://engineering.purdue.edu/~mark'
#  created 'enumerate.pl  2011-04-10  Mark Senn  http://engineering.purdue.edu/~mark'

use feature 'say';

use Math::Combinatorics;

my @rank  = qw(2 3 4 5 6 7 8 9 t j  q  k  a);
my @nrank = qw(0 1 2 3 4 5 6 7 8 9 10 11 12);
my @suit  = qw(c d h s);
my @nsuit = qw(0 1 2 3);

my @card = ();

foreach $nrank (@nrank)
    foreach $nsuit (@nsuit)
        push @card, chr((1 << 6) | ($nrank << 2) | ($nsuit));

my $comb = Math::Combinatorics->new(
    count => 10,
    data  => [@card],

while (my @dealt = $comb->next_combination)
    say @dealt;
===== program ends with previous line



To: purdue-pm at pm.org
From: Mark Senn <mark at purdue.edu>
Date: Fri, 01 Apr 2011 23:33:27 -0400
Subject: [Purdue-pm] challenge problems: "xoker" hands

"Xoker" is "extended poker".  I just made that name up.
A possible challege problem for the May meeting is to compare
two xoker hands and print "1" or "2" for if the first
hand or second hand wins.

for poker hand ranking.  Xoker has the additioal rules
to rank hands.  See the rest of this message for
the additional rules.

(I'm wondering if it would be easier to have
Perl code figure this out directly or have Perl
code reads a rule set and uses that rule set
to do the real work.)

Suits are not ranked equally.  In decreasing
order of value:

Xoker is played with one deck of the normal 52 cards.
After 10 cards are dealt (it's a two person game),
all the cards are shuffled before the next hand.

Each card has two parameters: a rank and a suit.  Ranks are
    2 3 4 5 6 7 8 9 10 j q k a
Suits are
    c d h s

Input to compare two hands is of the form, for example
    10c 8d ah 2s kd / 10s as ad 2h jd 7d
hand 1 is before the "/", hand 2 is after the "/".
Your program should do extensive error checking.

After the "One Pair" ranking but before the "High Card"
rankig insert:

    Rainbow: red card, black card, red card, black card, red card.
    Example: jh 8d 7d 4h ad (aces can be high or low)

    Bainbow: black card, red card, black card, red card, black card.
    Example: kc 10d 8c 5d 2s (aces can be high or low)

    Straight2: like a "Straight" except instead of adjacent cards it is
    "every other" card.
    Example: as qs 10d 8h 6d (aces can be high or low)

    Straight3: like a "Straight" except instead of adjacent cards it is
    "every third" card.
    Example: ks 10d 7d 4s ah

    Primes: Prime number cards.
    Example: 2s 3d 5h 7d jh
    Example: 3d 5h 7d jh kh

    Fibonacci: Fibonacci number cards, k 8 5 3 2 of any suit.
    Example: kc 8d 5d 3c 2c

Con you think of any other crazy rules to add?

Purdue-pm mailing list
Purdue-pm at pm.org

More information about the Purdue-pm mailing list