ChicoState / ChicoState/Dice

Refactor distribution to decimals

Open
#2 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
0
Forks
2
PR merge metrics
No merged PRs in 30d

Description

`get_distribution()` keeps a tally of how many times each face has been rolled, but some users are reporting that they want this same information as a percentage of total rolls.

Change this function to instead have the signature `vector GameDie::get_distribution()` that returns the *decimal* of rolls for each face relative to the number of *total* rolls. Each decimal should be a `double` between `0` and `1` inclusively. For example, if we have a 4-sided die that has rolled each face 1 time the `get_distribution()` function should return:
`{0.25,0.25,0.25,0.25}`

If there are no rolls yet, the function should report `0` for each face in the vector. Otherwise, the percentage should be calculated by **face rolls / total rolls**.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.