Git Product home page Git Product logo

die_roll's Introduction

Static Badge Static Badge Static Badge Static Badge

Dice Rolling Probability

Description


This project simulates a simple roll a die game. It possess two modes of dice rolling: unbiased dice rolling and biased dice rolling. The first one simulates a basic roll of all equally likely outcomes, while the second one favors one side of the die (left or right). ASCII art is used for dice faces, probability results and statistical plots are shown for addition.

dice_roll.py

The first input asks the user which die mode is gonna be played:

  • 1 for unbiased dice
  • 2 for biased dice.

Unbiased dice:

After entering 1, the user has to choose an amount of rollings (this amount can be any integer, but it's recommended to avoid any extremely high number). The outcome will print an array (same length as amount). Finally, the probabilities that each integer had, will be printed as well.

Biased dice:

After entering 2, just as unbiased dice, the user has to choose an amount. In this case, an input of a "favored side" will be prompted. If user chooses the left side there will be a higher probability for numbers 1, 2 and 3 to appear on the final array. On the contrary, if the right side is chosen there will be a higher probability for numbers 4, 5 and 6. And finally, the probabilities of each integer will be printed too.

Dice art diagrams:

Dice art diagrams are arranged in a dictionary where keys are integers from 1 to 6 and values are ASCII representations of dice faces corresponding to each integer. Dice faces will be shown below the final array in a single row. Be sure to have enough width on your terminal to print characters correctly.

Testing:

Type the following command to test dice_roll.py:

py -m pytest -v -s test_roll_a_die.py

die_roll's People

Contributors

cesia-cora 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.