PyPokerEngine icon indicating copy to clipboard operation
PyPokerEngine copied to clipboard

Straight with A,2,3,4,5 don't work

Open Simi2437 opened this issue 7 years ago • 3 comments

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 ;)

Simi2437 avatar Sep 27 '18 17:09 Simi2437

I have corrected your code in kind of youre Style.

Simi2437 avatar Sep 28 '18 06:09 Simi2437

Hi, it would be very helpful, if you can share your solution.

Arka2009 avatar Mar 20 '19 09:03 Arka2009

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).

schreven avatar May 20 '19 00:05 schreven