Skip to content

Refactor distribution to decimals #2

@kbuffardi

Description

@kbuffardi

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<double> 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions