Giter Club home page Giter Club logo

bingo's Introduction

What is traditional Bingo?

In the United States, Bingo is a game of chance in which each player matches numbers pre-printed in different arrangements on 5ร—5 cards with the numbers the game host draws at random, marking the selected numbers with tiles. When a player finds the selected numbers are arranged on their card in a row, they call out "Bingo!" to alert all participants to a winning card, which prompts the game host (or an associate assisting the host) to examine the card for verification of the win. Players compete against one another to be the first to have a winning arrangement for the prize or jackpot. After a winner is declared, the players clear their number cards of the tiles and the game host begins a new round of play. (Source - Wikipedia)

Let's define custom Bingo ๐Ÿ˜ƒ

Here we are going to define bingo in a bit different way. We will play bingo as follows:

  • Every player who is playing bingo comes up with a 3 x 3 matrix of his own choice ranging from numbers 1 to 20 (both inclusive). You may use the same integer more than once.
  • We will mark one square on your bingo board if you have at least one unmarked square that is a multiple of the total rolled (if more than one unmarked square is a multiple of the total, we will pick one at random).
  • We will take turns until at least one board has bingo (3 marks in a row, horizontal, vertical, or diagonal).
  • Each player whose board has bingo gets a share of the win (if n players get bingo, then each gets 1/n wins).
  • We will simulate 10,000 games (you can select some other number of your choice) using all the bingo boards submitted. The goal is to get the most wins out of all contestants.

Example

Now that you have understood the rules of the game let's look at an example ๐Ÿ’ก

  • Consider rolling the 2 dices 5 times and outcomes after adding both of them are 5,10,4,5 and 8 respectively.
  • Note that the 5 times are same as 5 turns and each turn is the sum of the numbers appearing on each dice.
  • At the first turn the sum of the dices is 5 so the algorithm will select a 5 or a multiple of 5 which in this case is 5,10 and 20. Lets say that the algorithm choose to select the lower-rightmost 5 in the image shown in green color.
  • We take the next turn and the sum of the dices in 10. The possible choices for the algorithm here are 10 and 20, let's say the algorithm select's 10 as shown in green color.
  • For the third turn we have 4. The possible choices are 4, 8 and 12, let's say the algorithm select's 8 located at the center of the matrix.
  • For the fourth turn we have 5 again. Now the multiples that are avialable to be marked are 5 located at the left-uppermost corner and 20.
  • โš ๏ธ Not that 5 located at lower-rightmost position and 10 is no longer available to be marked. This time the algorithm chooses the reamaining number 5 located at left-uppermost corner.
  • For the last turn we have 8. The only multiple of 8 in the matrix shown is 8 and there is only one 8 available which the algorithm can select one located at the middle of the last column.
  • All the elements selected (hypothetically) by the algorithm are shown in green circles. The blue row and the red column show the possible ways it would have been a bingo had the algorithm selected appropriate numbers but as mentioned in the rules in the intial section the algorithm can choose random number if there are more than one multiples unmarked (and this makes the problem or the game a great challenge of probability and statistics).

Simulating the game

  • You will find two folders in the bingo repository namely images and notebooks. The images folder has images which are intermediately used in the explanation in one of the ipython notebooks. The notebooks folder contains two ipython notebooks namely bingo.ipynb, play_bingo.ipynb and a bingo.py python script.
  • You shall notice that we are using the bingo.py file as module in play_bingo.ipynb. The bingo.py is a simple python script as opposed to the bingo.ipynb which is a jupyter notebook. We converted the file to simple python script so that we could use it as a module in the play_bingo.ipynb file.
  • bingo.ipynb conatins all the neccessary helper functions needed to simulate the game. I highly encourage you to look at the source code to have an better understanding of how the game is coded.
  • play_bingo.ipynb is the file which can directly simulate the game without knowing anything about the helper functions in the bingo.ipynb file. Please follow the instruction and read the description in the begining of the play_bingo.ipynb file to follow along.

Notes

  • Please feel free to mention your matrix and if it outperforms the one already mentioned, your name and matrix will be put on the learderboard ๐Ÿ†
  • Your submissions could help to benchmark the best matrix.

Thanks for taking time โฐ to stop by, please feel free to star โญ and fork ๐Ÿ”ง the repository or report any bug ๐Ÿชฒ in the code, in the issues section of the repository. ๐Ÿ˜ƒ

bingo's People

Contributors

ajaymache avatar

Stargazers

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