Skip to content

Error : KeyError: '28' #3

@tboulet

Description

@tboulet

I got an error by running the poker_main.py file (playing against an AI in a GUI). It happened the 3 times I played. With '25k' or other keys.

OS : windows 11
Python : 3.11.11
Env manager : uv 0.5.18
phevaluator : 0.5.3.1

Logs :

(venv) C:\Users\timot\projects\Poker-AI\game>python poker_main.py
Loading KMeans Flop Classifier kmeans_1719903872_samples=10000_bins=10.joblib
Loading KMeans Turn Classifier kmeans_1719904417_samples=10000_bins=10.joblib
C:\Users\timot\projects\venv\Lib\site-packages\pygame\pkgdata.py:25: UserWarning: pkg_resources is deprecated as an API. See https://setuptools.pypa.io/en/latest/pkg_resources.html. The pkg_resources package is slated for removal as early as 2025-11-30. Refrain from using this package or pin to Setuptools<81.
  from pkg_resources import resource_stream, resource_exists
pygame 2.6.1 (SDL 2.28.4, Python 3.11.11)
Hello from the pygame community. https://www.pygame.org/contribute.html
history:  ['5s5d', '4c3c']
Abstracted history:  ['5s5d', '4c3c']
Infoset key:  115
AI strategy  {'c': 0.09014976474975353, 'bMIN': 0.08879807236574992, 'bMID': 0.7715138145304645, 'bMAX': 6.589785831960461e-05, 'f': 0.04947245049571252}
Abstracted Action: bMID Final Action: b600
my hand with community cards:  ['4c', '3c', '4s', 'Qd', '9s']
Traceback (most recent call last):
  File "C:\Users\timot\projects\Poker-AI\game\poker_main.py", line 505, in <module>
    main()
  File "C:\Users\timot\projects\Poker-AI\game\poker_main.py", line 417, in main
    env.handle_game_stage()
  File "C:\Users\timot\projects\Poker-AI\game\../src\environment.py", line 308, in handle_game_stage
    self.play_current_stage(action)
  File "C:\Users\timot\projects\Poker-AI\game\../src\environment.py", line 171, in play_current_stage
    action = self.players[self.position_in_play].place_bet(self)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\timot\projects\Poker-AI\game\../src\aiplayer.py", line 221, in place_bet
    action = self.get_action(
             ^^^^^^^^^^^^^^^^
  File "C:\Users\timot\projects\Poker-AI\game\../src\aiplayer.py", line 294, in get_action
    strategy = self.postflop_infosets[infoset_key].get_average_strategy()
               ~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^
KeyError: '38k'

Also I don't see my cards on the GUI

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions