Docs


Randomisation functions

Runs of any game or scientific demo often need to rely on random numbers to be different each time. So we provide lots of random number support. You can roll your own too, of course.

 

AB.randomFloatAtoB ( A, B );         // return random float between A and B
AB.randomIntAtoB ( A, B );           // return random int between A and B

AB.randomEventProb ( p );            // return boolean should event of this probability happen now
AB.randomBoolean();                  // return random true or false 
AB.randomPick ( a, b );              // return a or b randomly 
AB.randomPick3 ( a, b, c );          // return a, b or c randomly 
AB.randomElementOfArray ( array );   // return random element of this array 

AB.randomColor();                    // return string '#nnnnnn' for use as color (e.g. in CSS)
AB.randomLightColor();               // return color string (light colors only)
AB.randomDarkColor();                // return color string (dark colors only)