I was testing the HandIndex4 routine, when I came across this oddity:
This combination of cards: 0 13 26 39 (for cards 2C 2D 2H 2S - a FOUR OF A KIND) returns an array index of 12076.
And, this combination also returns 12076: 0 13 27 15 (for cards 2C 2D 3H 4D - a PAIR).
Am I reading the function incorrectly? I was assuming that I would get a unique index number for each possible unique hand and was surprised when I came up with a duplicate.
Has anyone else used this function and might be able to shed some light on this?
Thanks
Quote: CrystalMathThe hands must me sorted first.
Are you sure? The reason I question that is because looping through the 2,598,960 combinations requires taking subsets of each of those hands and getting an index based on that subset of cards.
This hand, AC AD 3C 3D KS (12 25 1 14 50), is different than this hand, 3C 3D AC AD KS (1 14 12 15 50) with respect to the card value order of the cards, even though the evaluation of the hand would be the same, when looping through the ~2.6 million combinations (not the ~134K unique hands...that comes later).
As far as I'm aware these aren't supposed to be sorted. If they were sorted, they would be the same, and that would defeat the goal of getting all the different combinations on the draw which leads to the original problem of not having a unique index for the 2C 2D 2H 2S subset and the 2C 2D 3H 4D subset when looping through the ~2.6 million combinations.
Or have I completely missed the boat with all of this?
Quote: wannabemathguyAre you sure? The reason I question that is because looping through the 2,598,960 combinations requires taking subsets of each of those hands and getting an index based on that subset of cards.
This hand, AC AD 3C 3D KS (12 25 1 14 50), is different than this hand, 3C 3D AC AD KS (1 14 12 15 50) with respect to the card value order of the cards, even though the evaluation of the hand would be the same, when looping through the ~2.6 million combinations (not the ~134K unique hands...that comes later).
As far as I'm aware these aren't supposed to be sorted. If they were sorted, they would be the same, and that would defeat the goal of getting all the different combinations on the draw which leads to the original problem of not having a unique index for the 2C 2D 2H 2S subset and the 2C 2D 3H 4D subset when looping through the ~2.6 million combinations.
Or have I completely missed the boat with all of this?
No, AC AD 3C 3D KS and 3C 3D AC AD KS are two different permutations of the same hand. If you consider permutations rather than combinations, there are 52P5 = 311,875,200 of them, and you don't want to do that. You could, but it's just redundant.
Sort the cards in each hand (or partial hand) by card index and everything should work. Or some other sort order, just as long as its consistent.