Gamestudio Links
Zorro Links
Newest Posts
AlpacaZorroPlugin v1.3.0 Released
by kzhao. 05/22/24 13:41
Free Live Data for Zorro with Paper Trading?
by AbrahamR. 05/18/24 13:28
Change chart colours
by 7th_zorro. 05/11/24 09:25
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
4 registered members (AemStones, AndrewAMD, gamers, Kingware), 1,679 guests, and 2 spiders.
Key: Admin, Global Mod, Mod
Newest Members
LucasJoshua, Baklazhan, Hanky27, firatv, wandaluciaia
19054 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 | chip programmers | 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