Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re^2: RFC: Cribbage::Hand

by Limbic~Region (Chancellor)
on Mar 31, 2006 at 17:58 UTC ( #540519=note: print w/ replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    my %card;
    ++$card{$_} for @hand;
    ...
    # 2 * 1 = 2  (2  points for 2 of a kind)
    # 3 * 2 = 6  (6  points for 3 of a kind)
    # 4 * 3 = 12 (12 points for 4 of a kind)
    
  2. or download this
    0 = calculated score so far
    1 = flag indicating if any card has a value of 10
    2 = flag indicating if it is necessary to check for flush
    
  3. or download this
    # Find suits of any jack in the first 4 cards
    my %jack = map { $_ => 1 } substr($str, 0, 8) =~ /(?<=J)(.)/g;
    
    # Determine if the suit of the 5th card matches
    ++$score if $jack{ substr($str, -1, 1) };
    
  4. or download this
    # Get the unique list of suits in the first 4 cards
    my %suit = map {$_ => undef} unpack('xAxAxAxA', $str);
    ...
        # If cut-card matches, add 1 for that too
        $score += 1 if substr($str, 1, 1) eq substr($str, -1, 1);
    }
    

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://540519]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (13)
As of 2015-07-07 13:11 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (88 votes), past polls