ChicoState / ChicoState/GameDie

Add feature to report distribution as percentages

Open
#106 0 comments 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
C++
Stars
0
Forks
109
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.

Add a public member function `vector GameDie::get_percentages()` that returns the *percentage* of rolls for each face relative to the number of *total* rolls. Each percentage 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 and has the `get_distribution()` of:
`{1,1,1,1}`
then the `get_percentages()` function should return:
`{0.25,0.25,0.25,0.25}`

If there are no rolls yet, percentages 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

Research direction

Start at the GameDie public API and the existing get_distribution() implementation. Add the requested percentage-returning function, including the zero-roll case, and verify that each result is between 0 and 1 and sums to 1 after rolls.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
game-dev
Issue type
Feature
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.