in reply to Texas Hold'ems Poker Analysis Tool

$winner[0] = $hand_rank[0]; $winner[1] = $hand_rank[1]; $winner[2] = $hand_rank[2]; $winner[3] = $hand_rank[3]; $winner[4] = $hand_rank[4]; $winner[5] = $hand_rank[5];
This ugly fragment is repeated 6 times itself! If those are the only interesting elements in the arrays, try @winner=@hand_rank;.

But, I wanted to point out the interesting:

@winner[0..5]= @hand_rank[0..5];
Also, I think you would have more oppertunity for combining things if you declared the players as an array, not individual variables. E.g. the lines push (@p2_hand, pop @shuffled_deck); differ only in a digit.

—John

Replies are listed 'Best First'.
Re: Re: Texas Hold'ems Poker Analysis Tool
by Elgon (Curate) on Sep 06, 2002 at 14:21 UTC

    Hi John,

    Thanks for the reply: This is one of the boneheadednesses of which I spoke in the original post. Ah, stupidity knows no bounds! In this case, there will only ever be a maximum of 6 elements in the array:

    1. The ranking of the hand (1 element)
    2. A maximum of five 'kicker' card values/pair values etc...

    NB - It is important that, in the case that fewer kickers/values being required, the others are set to zero or anulled. I guess that the array slice assignation is probably best. Ta.

    I'd already thought of combining all the players into an array (as this would definitely be a good way ultimately to cut down on code-length) but I'd not got around to incorporating it into the code yet as I'm trying to teach myself C at the moment and I'm just about getting to grips with pointers.

    Elgon

    "Rule #17 of Travel: Never try and score dope off Hassidic Jews while under the impression that they are Rastafarians."
           - Pete McCarthy, McCarthy's Bar

      That actualy reminds me of one of my early attempts at programming, which I did on paper before having any real contact with a computer. It was to play blackjack. A friend had a dial-up terminal and we used it to play Zork, and then to run some BASIC/Fortran tutorials. That's all I knew, but I was hooked!

      When I really did learn how to program, it was with the manual from Radio Shack that came with their original "Pocket Computer". 1K of RAM, 24-character display.