The Texas Holdem application can be used to simulate poker hands. Once launched, a user will be shown a poker board with empty hands and all 52 cards to choose from. Users will be able to select their hand as well as the number of opponents and their hands. Based on the hands chosen, the program will show the implied odds or probability of winning and losing. From the cards still available, the program will simulate the flop, turn and river. After, the program will show which hand won.
The project will be done in python using the pygame library which is fast and easy to use for developers that have not had much experience with python or making programs that include UI. Github will be used for the version control.
Follow this project board to know the latest status of the project: https://github.com/orgs/cis3296s24/projects/86/views/1
Above is an image of what the application looks like.
- Make sure you have Python installed. You can download it from here.
- Install Pygame by running the following command: pip install pygame OR pip3 install pygame
- Git clone https://github.com/cis3296s24/03-Texas-Holdem
- Navigate to the project directory: cd projectName
- To run the game, execute the following command in terminal: python homepage.py
Pygame should run and display, if issues, following tips may be helpful:
- Main Branch: Use for stable and latest releases.
- Missing library/package to download: If compiling error make sure to have all downloaded onto IDE:
- joblib
- numpy
- pip
- pygame
- pygame-menu
- pyperclip
- scipy
- typing_extensions
- Mouse/ cursor: Used to navigate and use program interface
- Select number of computer players
- Click 'start' button
- Select 2 cards for every computer player with dropdown
- Click 'Run Flop' to simulate flop
- Click 'Generate' to generate winning rate
- Click 'Reset' to restart game
- Preious 3 steps can be done inconurrently
Main features of program:
- Program creates a new window through Pygame that displays a poker table.
- Program has custom UI poker theme with graphics, colors, fonts
- Program as light/dark mode
- Program has help menu
- Program can have multiple computer players (1-5)
- Program is able to customize each players’ cards in hand
- Program calculates the win rate for each player by simulating the table's card.
- Program is able to keep track of cards selected in order to simulate the flop, and win rate.
- Program is able to reset
Below is for 5 files that handle main functionality
- Dropdown Menu: Allows selection of the number of computer players.
- Start Button: Initiates the game with the selected number of players.
- Dark Mode Toggle: Enables switching between light and dark modes for the interface.
- Instructions Button: Opens game instructions in a separate Python file.
- Card Selection: Users can select a card from the dropdown menu.
- Scrollbar: A scrollbar is included to navigate through the list of available cards, especially when the list exceeds the visible area.
- Random Card Selection: Provides a method (
get_random_cards
) to select random cards from the available options, excluding those already selected. - Event Handling: Handles mouse events for button clicks, dropdown opening/closing, and scrollbar dragging.
- Drawing Dropdown Menu: Draws the dropdown menu on the screen, including the options and scrollbar.
- Displaying Selected Card: Displays the selected card's image on the screen for demonstration purposes.
- Pygame Setup: Initializes Pygame, sets the screen size, clock, and running state.
- Dropdown Menu: Implements a dropdown menu for selecting playing cards.
- Button Interactions: Responds to button clicks for reset, running flop, and calculating win rates.
- Color Modes: Supports both light and dark color modes for the interface.
- Image Handling: Loads and resizes images for the poker table background and playing cards.
- Card Conversion: Converts strings representing cards into Card objects for processing.
- Random Card Selection: Selects random cards excluding those already selected.
- Event Handling: Manages mouse events for button clicks and dropdown interactions.
- Drawing Interface: Draws the graphical interface including buttons, dropdown, selected cards, and flop.
- Card Display: Displays selected cards on the screen with their corresponding images.
- Win Rate Calculation: Calculates win rates based on selected cards and number of players.
- Winner Identification: Identifies the winner based on the highest ranking hand.
- Initializes: Initializes a set of cards representing a poker hand for each player.
- Print Win Rate: Simulates poker games with the given hands and prints the win rates for each player.
- Evaluation:Efficient NumPy operations for hand evaluation.
- Identify:Support for identifying various poker hand ranks.
- Special Cases:Handling of special cases such as ace-high and ace-low straights.
- Stores Results:Utilizes NumPy arrays for storing intermediate results.
- Extension and Modification:Modular structure allowing easy extension and modification of hand ranking logic.
Video showing demo of program running. Click image to play.
Over 4 weeks, we crafted a tool to assist poker players in their Texas Hold'em games. Born from our love for programming and poker, we developed a solution to simplify hand evaluation and enhance gameplay.
Using agile methods like Scrum, we worked collaboratively, adapting to changes and delivering improvements iteratively. Comprehensive testing ensured our program's reliability and accuracy, instilling confidence in its functionality.
As we conclude this phase, we thank everyone involved for their contributions. We're proud of what we've achieved and excited to see how our program will benefit poker players.
Thank you for considering Texas Hold'em for your poker needs. Happy coding, and may the best hand win!
Authors: Joe Zhou, Jasmine Liu, Arjun Patel, Vincent Schetroma, Jacob Creasy