Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
Simi2437 opened this issue Sep 27, 2018 · 3 comments
Open

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

Simi2437 opened this issue Sep 27, 2018 · 3 comments

Comments

@Simi2437
Copy link

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
Copy link
Author

I have corrected your code in kind of youre Style.

@Arka2009
Copy link

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

@schreven
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants