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.

DarkBASIC Discussion / help with random number stuff.....

Author
Message
Your mother
20
Years of Service
User Offline
Joined: 21st May 2005
Location:
Posted: 22nd May 2005 15:36
no matter how i tweak it, it outputs the same 4 numbers every time....all zeros, please help me make it work right...
Mentor
22
Years of Service
User Offline
Joined: 27th Aug 2002
Location: United Kingdom
Posted: 23rd May 2005 00:52
(a) no source

(b) already several threads on this subject

(c) use search

(d) I am so kind, 4 random numbers from 0 to 100

for i=1 to 4
print rnd(100)
next i
wait key

Mentor.

PC1:XP, P4 3ghz, 1gig mem, 3x160gig hd`s, Radeon 9800pro, 6 way sound.
PC2: Linux, AMD 2ghz, 512mb ram, Nvidia GeForce4mx, 16 bit SB.
PC3: XP, laptop, intel 2.6ghz celeron, ATI 9000igp, 256mb
Your mother
20
Years of Service
User Offline
Joined: 21st May 2005
Location:
Posted: 23rd May 2005 02:13
i know there have been a bunch, and ive read alot of them, and these numbes should be random, but they're not!

DARKGuy
21
Years of Service
User Offline
Joined: 28th Nov 2003
Location:
Posted: 23rd May 2005 23:39
Hm, strange... try putting "randomize timer()" in the -first- line of the code? it works for me, at least, in all the codes I've made :/

Mentor
22
Years of Service
User Offline
Joined: 27th Aug 2002
Location: United Kingdom
Posted: 24th May 2005 02:36
on line 3 you let cn= a random number from 0 to 5

on line 4 you let cn equal an array element from 0 to 3 that in that example is undefined, so if you run that code you get

0
0
0
0

where 0 is the contents of colors(0) to colors(3)

if this is part of a larger code example then you may have meant line 4 to read

colors(c)=cn

that will store the random colours in the array elements 0 to 3 rather than set cn to the contents of of the array (that negates the purpose of line 3, hope that helps.

Mentor.

PC1:XP, P4 3ghz, 1gig mem, 3x160gig hd`s, Radeon 9800pro, 6 way sound.
PC2: Linux, AMD 2ghz, 512mb ram, Nvidia GeForce4mx, 16 bit SB.
PC3: XP, laptop, intel 2.6ghz celeron, ATI 9000igp, 256mb
Robot
20
Years of Service
User Offline
Joined: 27th May 2004
Location:
Posted: 24th May 2005 06:21
Try this


the timer was the same everytime it loopes so they all had to be the same

The happenings of tommorow are behind us now
thinkdigital
21
Years of Service
User Offline
Joined: 18th Oct 2003
Location:
Posted: 30th May 2005 06:23 Edited at: 30th May 2005 06:24
Yes, randomize timer won't work like that.

[b]eGeneric Works : Dark Basic Developer Website

Login to post a reply

Server time is: 2025-05-23 00:10:48
Your offset time is: 2025-05-23 00:10:48