Skip to content

Document the distribution of Phaser.Math.RND.weightedPick inside its JSDoc #7300

@Bertie690

Description

@Bertie690

Currently, the weightedPick function fails to mention precisely how much earlier items in the array are favored over later ones, which is a fairly important detail to simply omit without warning.

Admittedly, the provided code isn't the clearest in the world either...

    weightedPick: function (array)
    {
        return array[~~(Math.pow(this.frac(), 2) * (array.length - 0.5) + 0.5)];
    },

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions