in reply to Optimising combinatorial iterations by filtration

This is likely the wrong way to go about this. I don't need to iterate over all of the poker hands to know that there are 52!/47!/5! of them, that 52-4 have 4 aces, 4*48*47/2 have 3 aces, 13*4*12*6 are full houses, 13*4*48*47/2 have 3-of-kind in them so 13*4*48*47/2-13*4*12*6 are 3-of-kind hands, etc.

Those are the types of calculations that you need to make, rather than just counting (if you want to do this fast enough to be useful in real time).

I suppose you could try doing weighted combinations where instead of combinations of cards you do combinations of classes of cards. For example, if the only types of cards that will change the standings are an ace or a spade, then you'd do combinations of the following classes: non-spade aces, ace of spades, non-ace spades, non-ace non-spades. Those combinations then lead to calculations like I was doing above. I not sure that would be any simpler.

You could look at my Permuting with duplicates and no memory (now part of Algorithm::Loops) and compare it to a standard lexicographic permutations combinations algorithm to see how my changes deal with duplicates and try to make similar changes to one of the combinations algorithms. Likely, you could search and find an algorithm for doing combinations with duplicates somewhere.

- tye        

  • Comment on Re: Optimising combinatorial iterations by filtration (mu)

Replies are listed 'Best First'.
A reply falls below the community's threshold of quality. You may see it by logging in.