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

Key error in treys.evaluator #12

Open
VinQbator opened this issue Feb 7, 2019 · 5 comments
Open

Key error in treys.evaluator #12

VinQbator opened this issue Feb 7, 2019 · 5 comments

Comments

@VinQbator
Copy link

VinQbator commented Feb 7, 2019

Getting this after thousands of iterations with RL algo. Apparently our hand + community cards add up to 8 cards for some reason and evaluator can't rank this hand.

/usr/local/lib/python3.6/dist-packages/holdem-1.0.0-py3.6.egg/holdem/env.py in _resolve_round(self, players)
    383       # compute hand ranks
    384       for player in players:
--> 385         player.handrank = self._evaluator.evaluate(player.hand, self.community)
    386 
    387       # trim side_pots to only include the non-empty side pots

/usr/local/lib/python3.6/dist-packages/treys-0.1.3-py3.6.egg/treys/evaluator.py in evaluate(self, cards, board)
     33         """
     34         all_cards = cards + board
---> 35         return self.hand_size_map[len(all_cards)](all_cards)
     36 
     37     def _five(self, cards):

KeyError: 8
@bdach
Copy link
Contributor

bdach commented Feb 7, 2019

I can't really think of a reasonable explanation for passing 8 cards to treys, so I'd gamble this is on the holdem side.

I'll look into it, but a reproducer example or at least debug output would be thoroughly welcomed.

@bdach
Copy link
Contributor

bdach commented Feb 7, 2019

I've also merged in some changes to end conditions to master that haven't since been deployed to pip, so you could try that version. Keep in mind that it might be unstable (#10 is a known issue, I haven't had time to look into it yet)

You can add git references via requirements.txt as follows:

git+https://github.com/wenkesj/holdem@master#egg=holdem

@BigBadBurrow
Copy link

Yeah I was getting this as well with the latest code commit where you changed/added this in env.py:

    if all([player.playedthisround for player in players]):
      self._resolve(players)

    terminal = False
    if all([player.isallin for player in players]):
      while self._round < 4:
        self._deal_next_round()
        self._round += 1
    if self._round == 4 or len(players) == 1:
      terminal = True
      self._resolve_round(players)
    return self._get_current_step_returns(terminal)

On the face of it the logic looks right, but something's amiss and it's causing extra community cards to be dealt. I rolled back to previous version with the addition of or len(players) <= 1 and it works fine:

    else:
      self._resolve(players)

    terminal = False
    if self._round == 4 or len(players) <= 1:
      terminal = True
      self._resolve_round(players)
    return self._get_current_step_returns(terminal)

@VinQbator
Copy link
Author

It already works fine in the PR I made. Been running for millions of hands and haven't seen any errors from environment for days.

@BigBadBurrow
Copy link

Sorry, I wasn't up-to-speed with the changes you'd made, so you may have fixed it with the other commits you performed. I'll need to do some updates to my code.

unaeat pushed a commit to unaeat/holdem that referenced this issue Aug 24, 2020
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