You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It would be nice if it could return the 5 winning cards after evaluating each 5-card combination from the list of eg 7 cards passed.
Would it work to return the tuple of PokerHand followed by all 5 cards in the significant order to maintain the ability to sort? We'd need to make Card sortable, so High vs low Ace may catch us out here unless we supported a specific Ace Card instance being assigned a value of 1 or 14?
I don't mind putting a bit of work into it if you let me know if and how you'd like it implemented.
Thanks.
The text was updated successfully, but these errors were encountered:
In an older version I returned all the cards with the resulting hand and tried to make it sort like that, but it didn't work for a few cases - hence the current approach of just returning the relevant values.
However, what you want is doable with itertools.
import deck, itertools
d = deck.Deck(include_jokers=False)
d.shuffle()
hand, = d.deal_hands(1, 7)
candidates = itertools.combinations(hand, 5)
for cards in sorted(candidates, key=deck.get_poker_hand, reverse=True):
print(deck.get_poker_hand(cards)[0], deck.Hand(cards))
It's not necessarily obvious, so it'd make a great example for the README (probably cleaned up a bit). My goal with this library was always to demonstrate how "transparently" you can reuse Python's builtins, rather than having to always define your own API for every single operation.
(As you point out, not being able to sort cards kind of goes against this ideal, but then it isn't actually possible to sort cards without specifying the rules. key= is how you do that, though if you look at the Hand class you'll see I've been playing with ways to make the contents of a given hand sortable.)
It would be nice if it could return the 5 winning cards after evaluating each 5-card combination from the list of eg 7 cards passed.
Would it work to return the tuple of PokerHand followed by all 5 cards in the significant order to maintain the ability to sort? We'd need to make Card sortable, so High vs low Ace may catch us out here unless we supported a specific Ace Card instance being assigned a value of 1 or 14?
I don't mind putting a bit of work into it if you let me know if and how you'd like it implemented.
Thanks.
The text was updated successfully, but these errors were encountered: