Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

irandom_weighted

Vašek edited this page Feb 7, 2019 · 5 revisions

irandom_weighted

Randomly selects a position based on the given probability.

Syntax:

irandom_weighted(params int[] p)
Argument Description
params int[] p Chances for the specific positions

Returns: int

Description:

This function will randomly return a number of the position based on the given probability. Each number determines how often this position will be chosen. For example: irandom_weighted(1, 1) This function has a 50% chance to return 0 and 50% to return 1.

Example:

int value = irandom_weighted(15, 15, 20);

This function has 30% chance to return 0, 30% to return 1 and 40% to return 2.

Example 2:

int value = irandom_weighted(1,999);

In this function there is only 0.1% chance to return 0 and 99,9 chance to return 1.

Back to number_functions

Clone this wiki locally

AltStyle によって変換されたページ (->オリジナル) /