Différences entre les versions de « EASEA defined functions »
Aller à la navigation
Aller à la recherche
Ligne 1 : | Ligne 1 : | ||
= Random Number Generators = | = Random Number Generators = | ||
− | == | + | == tossCoin == |
=== Description === | === Description === | ||
− | Simulates | + | Simulates a (possibly biased) toss of a coin. |
− | |||
− | |||
=== EASEA syntax === | === EASEA syntax === | ||
− | bool tossCoin() | + | bool tossCoin() // returns true with probability .5 |
− | bool tossCoin( | + | bool tossCoin(fBias) // returns true with probability fBias, with fBias in [0,1] |
− | === Example === | + | === tossCoin Example === |
− | if( tossCoin( | + | if(tossCoin(.1)){ // 10% chance to execute this code |
... | ... | ||
} | } |
Version du 1 juin 2020 à 02:59
Random Number Generators
tossCoin
Description
Simulates a (possibly biased) toss of a coin.
EASEA syntax
bool tossCoin() // returns true with probability .5
bool tossCoin(fBias) // returns true with probability fBias, with fBias in [0,1]
tossCoin Example
if(tossCoin(.1)){ // 10% chance to execute this code ... }
Random
Description
Generates a random number. There are several definitions to the random function:
- Random function with Min Max Boundary
- Random function with Max Boundary only
In the case of a Max boundary only, the Min boundary will be 0.
EASEA syntax
int random( int Min, int Max)
int random( int Max)
float random( float Min, float Max)
double random( double Min, double Max)