Straight with A,2,3,4,5 don't work
I work right now on a solution for my other problem and found this issue in your code too.
Wright me if you want to see my solution. I can come with a full solution for the hand evaluator ;)
I have corrected your code in kind of youre Style.
Hi, it would be very helpful, if you can share your solution.
I fixed this on my branch if you're interested. The change is in hand_evaluator.py; Change the function __search_straight to:
def __search_straight(self, cards):
bit_memo = reduce(lambda memo, card: memo | 1 << card.rank, cards, 0)
bit_memo = bit_memo | 2<<(1<<13&1)
rank = -1
straight_check = lambda acc, i: acc & (bit_memo >> (r+i) & 1) == 1
for r in range(1, 11):
if reduce(straight_check, range(5), True): rank = r+4
return rank
I just copied the A bit to the 1 bit, and adapted the for loop to start at 1. For cleanliness I also reduced the size of the for loop to what is necessary (from 14 to 11) and changed the value of the rank to what it is conventionally named in poker (as the top card).