Git Product home page Git Product logo

poker-calculator's Introduction

Purpose

This program asks you to enter how many different poker hands you want to draw from a deck of cards

It will then calculate of those hands how many were a one pair, two pair, ..., royal flush.

In the end it prints out how many times each card combination happened

Images

Program load, empty form

First run of program with 1000 trials

Second run with 50000 trials (including previous 1000 hence 51000). Note the runtime

Libraries used

  • tkinter, displays program window and UI
  • random, shuffles deck
  • copy, creates a copy of the deck for reshuffling
  • defaultdict, used for creating dictionaries with default values when calculating hand combinations
  • json, saving and loading data to and from a json file

Files

  • main.py - houses core logic
  • deck.py - manages cards in the deck and related functions that are more verbatim
  • check.py - manages functions that calculate what hand combinations exist in a hand
  • count_tk - manages outputting, saving, and loading data

How it works

The program begins in main.py

As for the user it begins when they enter a number value in the input box, txt_trials

Then hit the submit button, btn_calculate. This can call 1 of 2 functions:

  • click(), main function housing core logic
  • test(), can be used to manually test card combinations

Data carryover

If you want to retain data between runs of the program go to count_tk.py

Inside __init__(), there is a call to a function self.reset()

If reset() is commented, data between program runs will carry over

If reset() is uncommented, data will reset each time the program runs

Backstory

This was my first python project. My goal was to use all the fundamentals I learned and build something with it

Ive always loved playing cards. I thought that a project concerning them would be a great opportunity to practice algorithmic thinking as well

I decided on making a poker related project because I was playing it with my friends at the time for fun at home

I was interested in finding out how often rare hand combinations, like royal flush, occur in comparison to common combinations, like one pair.

poker-calculator's People

Contributors

waqaspathan00 avatar

Watchers

 avatar

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.