Différences entre les versions de « EASEA defined functions »

De
Aller à la navigation Aller à la recherche
Ligne 1 : Ligne 1 :
 
= Random Number Generators =
 
= Random Number Generators =
  
== TossCoin ==
+
== tossCoin ==
  
 
=== Description ===
 
=== Description ===
  
Simulates the toss of a coin. There are two different definitions of the tossCoin function:
+
Simulates a (possibly biased) toss of a coin.
#A simple toss of a coin.
 
#A biased toss of a coin.
 
  
 
=== EASEA syntax ===
 
=== EASEA syntax ===
  
  bool tossCoin()               // SImple tosscoin
+
  bool tossCoin()   // returns true with probability .5
  
  bool tossCoin(float bias)  // Biased tossCoin
+
  bool tossCoin(fBias)  // returns true with probability fBias, with fBias in [0,1]
  
=== Example ===
+
=== tossCoin Example ===
  
  if( tossCoin(0.1)){
+
  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:

  1. Random function with Min Max Boundary
  2. 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)