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.

Newcomers DBPro Corner / Random Numbers?

Author
Message
GameTiger101
21
Years of Service
User Offline
Joined: 24th Jun 2003
Location:
Posted: 25th Jun 2003 01:19
I am brand new to this software. I havent even played with it yet. Lookin in the manual I wonder:

Can you set values to random numbers?

-GameTiger101
BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 25th Jun 2003 01:43
These 2 lines pick a random seed, based on the timer, then sets x to a random number between 1 and 10.

RANDOMIZE TIMER()
X = RND(10)

Thanks in advance.
All the Best,
StevieVee
Gamer
21
Years of Service
User Offline
Joined: 29th Apr 2003
Location:
Posted: 25th Jun 2003 09:46
I think that sets a random # between 0 and 10.

GameTiger101
21
Years of Service
User Offline
Joined: 24th Jun 2003
Location:
Posted: 25th Jun 2003 23:30
That was my next question... That would give me a value of: 0,1,2,3,4,5,6,7,8,9, or 10

Right?

-GameTiger101

Scorpyo
22
Years of Service
User Offline
Joined: 26th Aug 2002
Location: italy
Posted: 26th Jun 2003 01:51
well try it out

Do
x=rnd(10)
set cursor 0,0
print "your random value is : ",x
print "press any key to continue, Esc to exit"
wait key
cls
Loop
Nilrem
21
Years of Service
User Offline
Joined: 27th Feb 2003
Location: United Kingdom
Posted: 26th Jun 2003 01:51
Yes, and everytime you load the program it would be a different number, but without the line
it would be the same number each time.

By the way it'll either start from 1 to 10 or 0 to 10, I think it's 0 to 10 but I'm not totally sure.

I hear and I forget. I see and I remember. I do and I understand.
Bloodshot
21
Years of Service
User Offline
Joined: 7th Apr 2003
Location: United Kingdom
Posted: 26th Jun 2003 19:03 Edited at: 26th Jun 2003 19:09
Yes, Rnd() starts at 0

So, to simulate a coin toss:





If you do want a value to start at 1, simply do this:

ROLL=Rnd(5)+1 : Rem Simulate the values of a standard 6 sided dice (1 to 6)


Example:

indi
22
Years of Service
User Offline
Joined: 26th Aug 2002
Location: Earth, Brisbane, Australia
Posted: 27th Jun 2003 23:05
role playing die functions as well



Rhaythe
21
Years of Service
User Offline
Joined: 30th Jun 2003
Location:
Posted: 1st Jul 2003 20:03
"If you do want a value to start at 1, simply do this:

ROLL=Rnd(5)+1 : Rem Simulate the values of a standard 6 sided dice (1 to 6)"

Oh my god! I almost kicked myself when I saw this. I just recently purchased DB and was trying to find out if there was a way to do a random number within a range. Such a simple way that it made me want to cry.

By the way I'm obviously new here. To give an example of the last time I used any type of BASIC, it was when they actually used line numbers at the beginning of each line.

Trying to recall the little I knew before.

Rhaythe

GameTiger101
21
Years of Service
User Offline
Joined: 24th Jun 2003
Location:
Posted: 2nd Jul 2003 02:16
Thank you much all. This answers my question to the fullest extent!

x-d

-GameTiger101

Login to post a reply

Server time is: 2024-09-20 13:44:48
Your offset time is: 2024-09-20 13:44:48