• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

SOLVED Are random Bools a thing?

Mr Magnus

Viking King
Either use irandom(1), or choose(true,false).

In GML any value higher than or equal to 0.5 is true, anything below that is false.
 

Mr Magnus

Viking King
may you give an example?
GML:
variable = 1 // true

variable = 0 // false

variable = irandom(1) // true half the time, false half the time. Make sure you call randomize() once at the beginning of the game

variable = choose(true, false) //true half the time, false half the time

variable = choose(true, true, false) // True 2/3rd of the time, false 1/3rd of the time

variable = random(1) < 0.5 //True half the time, false half the time

variable = random(100) < 50 //true half the time, false half the time
 
Last edited:
GML:
if (((irandom(1) == 1) == true) ? true : false)
{
  return true;
}
else
{
  return false;
}
:p
true is literally triggering, I prefer
GML:
if (((irandom(1) == 1) == !false) ? !false : false){ return !false; }else{ return false; }
Now can we discuss banker's rounding and how you can slightly improve your odds of !false using irandom(1) == 0 or irandom_range(1,2) == 2?
 
Top