Pardon the mess, Play My Code is in beta!

READY TO PLAY?
CLICK TO LOG IN!

sign up - lost password

randBoolean

This is for quickly generating a random true, or false. It is useful for being able to randomly chose to do something, such as choosing if the enemy should fire at the player.

randBoolean()

Randomly returns true or false. On average, it aims to have a 50% chance to return true or false.

randBoolean( probability )

Randomly returns true, but the likely hood is based on the 'probability' value. The chance of returning true is '1 in probability', where tries is a positive integer.

// a 1 in 10 chance of executing the if statement
if randBoolean(10)
    // do something
end

So if 'probability' is 10, then it is a 1 in 10 chance, and if 'probability' is 100, then it has a 1 in 100 chance of returning true.