Giter Site home page Giter Site logo

poker's Introduction

Poker

This is a simple Texas Hold 'em game running on MacOS. All scripts are written in pure Python. The main GUI is written using the Python module PySimpleGUI, and hand evaluation is done by refering to a hand value table pre-calculated together with Monte Carlo simulation. See here for detailed explanation of hand evaluation. Together with the GUI version, I also include here a primitive commmandline version with ColorPrint support, which you may download and include from this repo. The two versions are supposed to work identically.

Usage

You don't need any Python or module dependencies installed on your Mac in order to just play the game. The app itself is standalone with everything packed inside it already. There're just two steps:

  1. Download the app from here.
  2. Double click it.

Or rather, if you'd like to pack it yourself:

  1. Download this repo.
  2. Pack it using PyInstaller in --onefile mode.
  3. Double click the app you just generated.

To-Do's

There're several things to work on in plan:

  • Fix bugs (please, don't again).

  • Write up AI agents of different strategies (in progress):

    • Expected hand value optimization (Greedy);
    • Game theory optimal (GTO);
    • Evolutionary algorithm (EA);
    • Deep Q-Learning (DQN).
  • Build a server-based version so multiple people can play on different divices.

  • Build an Android version (proposed by author of PySimpleGUI, MikeTheWatchGuy).

  • Fix GUI problems:

    • Resolution of image is extremely low and it looks ugly on Retina screens.
    • Button styles and other design-related issues.

Known Bugs

Here are some bugs I'm trying to fix:

  • Side pot. It's tricky and I havn't found a way to implement it simple.
  • Side pot. It's tricky and I havn't found a way to implement it simple.
  • Freeze at start. The app starts and then freezes for a sec. This is because Python is openning the hand value table. Perhaps I should try threading for this particular task (no need for the rest of the game). I'll also try to compress the table in a better way (like functionize it). Working on the animated Popup element in PySimpleGUI.

Acknowledgement

I appreciate suggestions and encourage from anyone throughout the development (which may still continue for a long time, considering the considerable time I spent just on writing this primitive game). Special thanks to my friends who ever tried to play the game and found bugs starting from the commmandline version. Also, credit for MikeTheWatchGuy who wrote the PySimpleGUI module and helped me fix several bugs. Also, credit to Freepik from www.flaticon.com, who made this fantastic icon. Finally, I wanna give credit to myself for the nights I stayed up after lectures. There is nothing more fulfilling than realizing an impulse right away.

poker's People

Contributors

allenfrostline avatar

Stargazers

Taras Hevlich avatar ManKit Pong avatar  avatar  avatar Jarl Robert Pedersen Heer avatar  avatar Armaan Amazan avatar Payas Parab avatar  avatar David SeWell avatar PySimpleGUI avatar  avatar  avatar MikeTheWatchGuy avatar

Watchers

James Cloos avatar David SeWell avatar  avatar

poker's Issues

[Enhancement] Proving user feedback during the "Freeze" portion

Mentioned in the readme was:

Freeze at start. The app starts and then freezes for a sec. This is because Python is openning the hand value table. Perhaps I should try threading for this particular task (no need for the rest of the game). I'll also try to compress the table in a better way (like functionize it).

There are a couple of things you can do so that it doesn't look like it's frozen.

  1. Show a progress bar while it's loading, providing an update on when it'll finish
  2. Show an animated "loading" GIF while loading

Both require you to make periodic calls into PySimpleGUI while you're doing your lengthy operation, so it will require some integrating of this part of your code with the GUI module.

Both methods can be done with a single line of code added to your code. If you your the animated Popup call then you only need that one line and you can use the Single Line Progress Meter call for a progress meter.

Of course you can do your own fancier stuff too.

Requesting requirements.txt file

Hi,

I'm quite interested in your project, would you mind uploading the requirements.txt file? That would be a huge help.

Thanks in advance

Crash when starting....

When running poker_gui.py, the file I assume you run to start playing, it crashes with this traceback:

C:\Python\Anaconda3\python.exe C:/Python/PycharmProjects/GitHub/Poker/poker_gui.py
Traceback (most recent call last):
  File "C:/Python/PycharmProjects/GitHub/Poker/poker_gui.py", line 523, in <module>
    g = Game(n_players=9, buy_in=10, seed='random')
  File "C:/Python/PycharmProjects/GitHub/Poker/poker_gui.py", line 42, in __init__
    self.__welcome()
  File "C:/Python/PycharmProjects/GitHub/Poker/poker_gui.py", line 68, in __welcome
    with absOpen('hv.json', 'r') as f: self.__hv = json.load(f)
  File "C:\Python\PycharmProjects\GitHub\Poker\misc.py", line 331, in absOpen
    return open(absPath(name), mode=mode, buffering=1)
FileNotFoundError: [Errno 2] No such file or directory: 'C:\\Python\\PycharmProjects\\GitHub\\Poker\\hv.json'

Windows 10 + Conda = Issue

I looked at sources, and tried to uninstall and re-install matplotlib with conda, but it still did not work.

I am simply going to use Linux for now, but this is an issue that should be fixed. Maybe this belongs in Anaconda + MatPlotLib as well.

(base) PS C:\Users\Admin\Downloads\Poker-master\Poker-master> python poker_gui.py
Traceback (most recent call last):
File "C:\ProgramData\Anaconda3\lib\site-packages\matplotlib\backends\tkagg.py", line 27, in blit
dataptr, colormode, bboxptr)
_tkinter.TclError: invalid command name "PyAggImagePhoto"

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "poker_gui.py", line 523, in
g = Game(n_players=9, buy_in=10, seed='random')
File "poker_gui.py", line 44, in init
self.__newGame()
File "poker_gui.py", line 191, in __newGame
self.__newRound(blind=True)
File "poker_gui.py", line 295, in __newRound
bet = self.__bet(i, n_round, blind)
File "poker_gui.py", line 441, in __bet
_ = drawFigure(window.FindElement('CANVAS').TKCanvas, fig)
File "C:\Users\Admin\Downloads\Poker-master\Poker-master\misc.py", line 478, in drawFigure
tkagg.blit(photo, figure_canvas_agg.get_renderer()._renderer, colormode=2)
File "C:\ProgramData\Anaconda3\lib\site-packages\matplotlib\backends\tkagg.py", line 28, in blit
except tk.TclError:
AttributeError: '_tkinter.tkapp' object has no attribute 'TclError'

Missing Window Icon + not sure how to play

When I see the window, I see the default tkinter icon.

After I see this screen, I don't seem to be able to do anything, at least nothing I click seems to do anything. I'll read through the code a bit and see what I'm missing.

image

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.