GithubHelp home page GithubHelp logo

bridgeshapetool's Introduction

BridgeShapeTool

The shape of a bridge hand is the set of lengths of the suits in the hand, i.e., an unordered 4-tuple (w,x,y,z) where w+x+y+z=13, and each w, x, y, z describes the length of a suit in the hand. For this project, we wrote a program that calculates the probability distribution of the shape of a random hand. The program is for Python 3.8 or above and uses the matplotlib and tkinter libraries. The program calculates all the probabilities of all hand shapes, plots the distribution, and includes a function to calculate probability of incomplete bridge shapes (e.g., (6,4,X,X)). To run the program, simply open BridgeShapeTool.exe. The start-up/runtime is about 10 seconds.

Bridge Hand Probability Calculations: To calculate the probability of a given shape the program does the following:

  1. Calculates the number of “floating suits”, i.e., the number of suit lengths that are equal in the shape of a hand. For example, (4,3,3,3) has 3 floating suits and (5,4,3,1) has 0 floating suits.
  2. Calculates the number of hands in a shape (w,x,y,z). Let a be the number of floating suits. Then #h= (4 choose 1) * ((4-1) choose 1) * … * ((a+1) choose 1) * (13 choose w) * (13 choose x) * (13 choose y) * (13 choose z)
  3. Calculates the probability of a given hand shape: P(w,x,y,z) = #h/(52 choose 13)

We also programmed a function that finds all the shapes associated with a given hand shape. If x1, … , xn (n=1,…,4) are the known numbers in the hand shape, then the code searches through all the hand shapes that have x1, … , xn in them, and outputs them. For example (6,4,X,X) outputs (6,4,2,1) and (6,4,3,0)

Icon image taken from https://www.hiclipart.com/free-transparent-background-png-clipart-icdim. We do not own the rights to the image, all credits go to the original creator who uploaded to hiclipart.com

bridgeshapetool's People

Contributors

startrekdude avatar seanm1011 avatar thomasfarley13 avatar

Stargazers

 avatar

Watchers

 avatar  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.