Code Monkey home page Code Monkey logo

siete's Introduction

siete

A simulation for a family bet game.

Game

The game consist in a number of players with 10 cards (from 2 to 12 except from 7) facing up so all players can see them. In each turn a player rolls a pair of dices. If the number he/she gets is 7, the player has to increase the pot by a given amount (usually 10 cents). If the number is one of the cards in his hand, he can turn that card and keep playing. If the number is not in his hand, he/she will have to check in the next player's hand. If the next player doesn't have the card, the current player can roll again, but if the next player has the card the turn is over and the next player can turn his card and roll the dices again.

The game ends when one player has no cards left. The winner takes the jackpot.

Simulation

Given the random nature of the game I wanted to simulate it and see if any pattern emerges. And indeed, there are (unless they are because of the pseudorandomness).

Run a simulated game

python3 siete.py

Multithreading vs Multiprocessing

In the code I experimented with both multithreading and multiprocessing functions and, as expected, only the multiprocessing approach had speed improvements. You can check the analyze notebook.

Exploring patterns

I recommend using the included analyze notebook to perform analytics on the simulations. A remarkable one is that with 11 players the first player has an incredible higher probability of winning the jackpot.

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.