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
2 registered members (NnamueN, 1 invisible), 1,489 guests, and 6 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() not random? #233710
10/30/08 00:57
10/30/08 00:57
Joined: Oct 2008
Posts: 22
S
SamstaUK Offline OP
Newbie
SamstaUK  Offline OP
Newbie
S

Joined: Oct 2008
Posts: 22
I Have been using the following code to randomly generate tornadoes on my map:

Quote:
var count = 1;
while(count<(random(10))){
ent_create("tornado.mdl",vector(random(20000),random(20000),0),tornado);
count = count + 1;
}


The problem is that they are in the same place each time? What am I doing wrong?

Re: Random() not random? [Re: SamstaUK] #233711
10/30/08 01:01
10/30/08 01:01
Joined: Oct 2008
Posts: 67
pewpew Offline
Junior Member
pewpew  Offline
Junior Member

Joined: Oct 2008
Posts: 67
random in computers usually isnt random. you need to set the random seed first i'd assume. i am new to c-lite but do a fair bit of c++.

go through the manual and search for random seed, then set it to the hours/minutes/seconds of the system clock. always works great.

something like:
srand(clock.seconds)
etc.

just once, at the start of your program


HURRR DERP DERP DEERRPP HURR
Re: Random() not random? [Re: pewpew] #233718
10/30/08 01:38
10/30/08 01:38
Joined: Jan 2002
Posts: 4,225
Germany / Essen
Uhrwerk Offline
Expert
Uhrwerk  Offline
Expert

Joined: Jan 2002
Posts: 4,225
Germany / Essen
The function that does this is called random_seed().

Here is the corresponding manual page: http://www.conitec.net/beta/avar-randomize.htm


Always learn from history, to be sure you make the same mistakes again...
Re: Random() not random? [Re: Uhrwerk] #233777
10/30/08 16:53
10/30/08 16:53
Joined: Jul 2008
Posts: 2,107
Germany
rayp Offline

X
rayp  Offline

X

Joined: Jul 2008
Posts: 2,107
Germany
I dont know if this helps...whats up with RANDOMIZE ?


Acknex umgibt uns...zwischen Dir, mir, dem Stein dort...
"Hey Griswold ... where u gonna put a tree that big ?"
1998 i married my loved wife ... Sheeva from Mortal Kombat, not Evil-Lyn as might have been expected
rayp.flags |= UNTOUCHABLE;
Re: Random() not random? [Re: rayp] #233801
10/30/08 18:31
10/30/08 18:31
Joined: Oct 2008
Posts: 22
S
SamstaUK Offline OP
Newbie
SamstaUK  Offline OP
Newbie
S

Joined: Oct 2008
Posts: 22
randomize() is what I used, random_seed() gave me errors for some reason.

Re: Random() not random? [Re: SamstaUK] #233806
10/30/08 18:55
10/30/08 18:55
Joined: Aug 2008
Posts: 218
U.S.
GamerX Offline
Member
GamerX  Offline
Member

Joined: Aug 2008
Posts: 218
U.S.
I use random(100); for example which would be 0-100 or random(100)50; 50-100 works fine for me;

If your doing it in a comparison try doing like
Code:
var r;
while(1){
r = random(100); wait(1);
while(example > r)
{
blahblahblah wait(1);}



"You may never know what results come of your action, but if you do nothing there will be no result."
-Mahatma Gandhi
Re: Random() not random? [Re: GamerX] #233835
10/30/08 21:15
10/30/08 21:15
Joined: Jan 2002
Posts: 4,225
Germany / Essen
Uhrwerk Offline
Expert
Uhrwerk  Offline
Expert

Joined: Jan 2002
Posts: 4,225
Germany / Essen
Sorry, thought you we're using lite-c not c-script. When using c-script you should use randomize(). Be carefull random(100) does not return random numbers from 0 - 100 but from 0 - 99.999.


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

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