GameMaker Question pls answer

J

James Lin

Guest
If I have a random_range(1, 5) can it return 1 or 5, or is it only 2,3, or 4?
 

TheouAegis

Member
It can return 1, but unless you use irandom_range(), I don't think it will return the 5. The random(n) function will not return n, so i assume it is the same for random_range(a,n).
 
Last edited:
T

Taddio

Guest
Neither.
Code:
random_range(1,5); //return antyhing between 1 and 5, including every fractions

irandom_range(1,5); //returns either 1,2,3,4 or 5

choose(1,3,5); //choose one of the argument provided

//Remember you can use variables in there too
It can return 1, but unless you use irandom_range(), I don't think it will return the 5. The random(n) function will not return n, so i assume it is the same for random_range(n).
Well, I think if you'd do:
Code:
var _a = random_range(1,5);
var _b = 1;

if( _a == _ b){
 //Do awesome stuff
}
Awesome stuff wouldn't come around very often. I don't know if it would ever trigger if _b=5, tho, I will take your word for it (plus, who would do that, really?).
 
Last edited by a moderator:
J

James Lin

Guest
Neither.
Code:
random_range(1,5); //return antyhing between 1 and 5, including every fractions

irandom_range(1,5); //returns either 1,2,3,4 or 5

choose(1,3,5); //choose one of the argument provided

//Remember you can use variables in there too

Well, I think if you'd do:
Code:
var _a = random_range(1,5);
var _b = 1;

if( _a == _ b){
 //Do awesome stuff
}
Awesome stuff wouldn't come around very often. I don't know if it would ever trigger if _b=5, tho, I will take your word for it (plus, who would do that, really?).
Thanks! This really clears up all of the questions I had about random numbers!
 

TheouAegis

Member
Neither.
Code:
random_range(1,5); //return antyhing between 1 and 5, including every fractions

irandom_range(1,5); //returns either 1,2,3,4 or 5

choose(1,3,5); //choose one of the argument provided

//Remember you can use variables in there too

Well, I think if you'd do:
Code:
var _a = random_range(1,5);
var _b = 1;

if( _a == _ b){
 //Do awesome stuff
}
Awesome stuff wouldn't come around very often. I don't know if it would ever trigger if _b=5, tho, I will take your word for it (plus, who would do that, really?).
LOL. The tests for what random() and random_range() return were boring. We would run it in a loop for an hour or more just to see if it would ever return the specified values. Nobody actually trusted the manual in the olden days when they realized there were a lot of typos in it.
 
T

Taddio

Guest
LOL. The tests for what random() and random_range() return were boring. We would run it in a loop for an hour or more just to see if it would ever return the specified values. Nobody actually trusted the manual in the olden days when they realized there were a lot of typos in it.
Geez, does indees sounds boring as ****...

[Guys at the office]
- "Boss, should we work on cool new features? Got a ton of ideas!"

[Boss]
- "Nah! Let's just run loops for hours and do pie graphs in Excel!"

:D
 
Top