Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Studio Chat / Random2() bug

Years of Service
User Offline
Joined: 22nd Aug 2016
Posted: 22nd Aug 2019 19:31 Edited at: 22nd Aug 2019 19:52
When I use the line:

num = Random2(-12,12) I expected num to have a different number when running the program multiple times. Instead, it produces 10 every time I run the program.

Here is the code in full:

If I change the numbers in the Random2() call, to say Random2(-20,20) it gives me a different result, but repeats that result everytime the program is run.

Putting in the line SetRandomSeed2(GetUnixTime()) corrects the problem.

The above code works fine in AGK2 Classic.

This appears to be a bug. Following the suggested steps, I post this for others to confirm or not.
Retired Moderator
Years of Service
User Offline
Joined: 11th Jan 2005
Location: Adelaide
Posted: 22nd Aug 2019 19:40
Confirmed random2 always returns the same value on classic in studio
calling SetRandomSeed2(GetUnixTime()) fixes this but it should automatically
call it at start up regardless
fubarpk on Itch...………...
fubarpk on googleplay..
Valued Member
Years of Service
User Offline
Joined: 10th Feb 2004
Location: Essex, UK
Posted: 22nd Aug 2019 20:46
Paul Johnston
TGC Developer
Years of Service
User Offline
Joined: 16th Nov 2002
Location: United Kingdom
Posted: 6th Sep 2019 14:23
Thanks, fixed for the next version
Years of Service
User Offline
Joined: 24th Feb 2005
Location: nm usa
Posted: 7th Sep 2019 00:41
thanks vitp fir the catch that would gave caused me some serious trouble eventually.

Login to post a reply

Server time is: 2020-07-04 12:37:44
Your offset time is: 2020-07-04 12:37:44