Melee Modding Library  2.0.0
A C library for modding Super Smash Bros Melee
Functions
random.h File Reference

Random number generation. More...

#include "gctypes.h"
#include "logic.h"

Go to the source code of this file.

Functions

float rand ()
 Generate random number in [0,1]. More...
 
float uniform (float a, float b)
 Sample uniformly from [a, b] . More...
 
unsigned sample (const float *probs, size_t size)
 Return index of array according to given probabilities. More...
 
bool chance (FunctionArg prob)
 Single 'coin flip' with given probability. More...
 

Detailed Description

Random number generation.

Function Documentation

float rand ( )

Generate random number in [0,1].

Returns
- Random floating point number in [0,1]
float uniform ( float  a,
float  b 
)

Sample uniformly from [a, b] .

Returns
random floating point number in [a, b]
unsigned sample ( const float *  probs,
size_t  size 
)

Return index of array according to given probabilities.

Parameters
probs- array of probabilities, must sum to 1
size- size of probability array
Returns
index of array
bool chance ( FunctionArg  prob)

Single 'coin flip' with given probability.

Parameters
prob- floating-point value in [0,1]
Returns
Returns true with probability prob