GithubHelp home page GithubHelp logo

dice_check's Introduction

Dice Roll Success Calculator

Introduction

This Dice Roll Success Calculator is a Go program designed to calculate the probability of achieving a specific success condition in a dice roll scenario. It can accommodate various configurations, including the number of dice, the number of sides on each die, a success threshold, the number of dice that must meet or exceed this threshold, and a modifier that can be applied to each roll.

Features

  • Flexible Configuration: Set up the dice roll simulation with custom values for dice number, dice sides, success threshold, required number of successful dice, and roll modifiers.
  • Modifier Distribution: Analyzes all possible distributions of a given modifier across all dice in a roll.
  • Success Calculation: Calculates the probability of a roll being successful under the given conditions.
  • Comprehensive Analysis: Generates all possible dice combinations based on the configuration and evaluates each for success.

Installation

To use this program, ensure you have Go installed on your system. Clone the repository to your local machine and navigate to the program's directory.

git clone <repository-url>
cd <program-directory>

Usage

  1. Configuration: Modify the main function in the program to set your desired configuration. For example:

    cfg := config{
        threshold:  4,
        successNum: 3,
        diceNum:    3,
        sides:      6,
        modifier:   1,
    }

    This configuration sets up a scenario with 3 six-sided dice, a success threshold of 4, at least 3 dice must meet or exceed this threshold, and a modifier of +1 to each roll.

  2. Running the Program: Compile and run the program using the Go command.

    go run main.go

    The program will output the process of generating dice combinations, the distribution of the modifier, and the final probability of success based on the provided configuration.

  3. Interpreting Output: The output will include detailed logs of each dice combination and whether it meets the success criteria. Finally, it will display the total number of successful combinations out of all possible combinations, along with the probability of success.

Example Output

Generate a table of all variants of the distribution of the modifier 1 on the number of dice=3
Table of distribution of modifier 1 on the number of dice = 3
 [[0 0 1] [0 1 0] [1 0 0]]

Generating all the combinations of 3d6
...
[1 2 3] :  false
[6 5 4] :  true
Successful rolls 100 of 216
Probability of success at 
{diceNum:3 sides:6 threshold:4 successNum:3 modifier:1} 
=0.46296296

This output demonstrates the program's process and final probability calculation, providing a clear indication of how likely a given dice roll configuration is to succeed under the specified conditions.

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.