Gamestudio Links
Zorro Links
Newest Posts
Zorro 2.70
by jcl. 09/29/25 09:24
optimize global parameters SOLVED
by dBc. 09/27/25 17:07
ZorroGPT
by TipmyPip. 09/27/25 10:05
assetHistory one candle shift
by jcl. 09/21/25 11:36
Plugins update
by Grant. 09/17/25 16:28
AUM Magazine
Latest Screens
Rocker`s Revenge
Stug 3 Stormartillery
Iljuschin 2
Galactic Strike X
Who's Online Now
1 registered members (TipmyPip), 18,388 guests, and 6 spiders.
Key: Admin, Global Mod, Mod
Newest Members
krishna, DrissB, James168, Ed_Love, xtns
19168 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Random problem #364676
03/19/11 21:56
03/19/11 21:56
Joined: Dec 2010
Posts: 87
R
romin2011 Offline OP
Junior Member
romin2011  Offline OP
Junior Member
R

Joined: Dec 2010
Posts: 87
Hello, how to create a function to take 2 variables min & max values and return a random number between them?
It looks easy but i dont know why at the moment my mind cant figure it out maybe i need rest? Thanx

Re: Random problem [Re: romin2011] #364690
03/20/11 00:09
03/20/11 00:09
Joined: Jan 2002
Posts: 4,225
Germany / Essen
Uhrwerk Offline
Expert
Uhrwerk  Offline
Expert

Joined: Jan 2002
Posts: 4,225
Germany / Essen
Code:
fixed my_random(fixed min,fixed max)
{
	return min + random(max - min);
}




Always learn from history, to be sure you make the same mistakes again...
Re: Random problem [Re: Uhrwerk] #364750
03/20/11 15:13
03/20/11 15:13
Joined: Dec 2010
Posts: 87
R
romin2011 Offline OP
Junior Member
romin2011  Offline OP
Junior Member
R

Joined: Dec 2010
Posts: 87
hey thanx Uhwerk it works wink

Re: Random problem [Re: romin2011] #364752
03/20/11 15:44
03/20/11 15:44
Joined: Feb 2010
Posts: 886
Random Offline
User
Random  Offline
User

Joined: Feb 2010
Posts: 886
Mist, to late...



Re: Random problem [Re: Random] #364867
03/21/11 17:25
03/21/11 17:25
Joined: Mar 2010
Posts: 120
Switzerland
T
TehV Offline
Member
TehV  Offline
Member
T

Joined: Mar 2010
Posts: 120
Switzerland
It might be important to mention that the value it returns isn't really random - for example, the first time I run random(10000) after starting the engine, it returns 8743.

Re: Random problem [Re: TehV] #364868
03/21/11 17:36
03/21/11 17:36
Joined: Jan 2002
Posts: 4,225
Germany / Essen
Uhrwerk Offline
Expert
Uhrwerk  Offline
Expert

Joined: Jan 2002
Posts: 4,225
Germany / Essen
Yes, of course. "Random" numbers are never really random. If you want to avoid getting the same random numbers every time you start the engine you can use random_seed for this purpose.


Always learn from history, to be sure you make the same mistakes again...

Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

Gamestudio download | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1