rnd() question

Post Reply
mrRothchildsjr
Posts: 6
Joined: Wed Nov 05, 2014 6:22 pm

rnd() question

Post by mrRothchildsjr »

Example:

varsleep = 0

10 d1 = int(RND * 6 + 1)

print d1

11 varsleep = varsleep + 1

pause(.1)

if varsleep = 10 then goto 13

12 goto 10

13 print "done!"


Hi! Why do I get ten 1s instead of pseudo-random dice rolls each time I execute?

User avatar
Mr. Kibernetik
Site Admin
Posts: 4786
Joined: Mon Nov 19, 2012 10:16 pm
My devices: iPhone, iPad, MacBook
Location: Russia
Flag: Russia

Re: rnd() question

Post by Mr. Kibernetik »

Because you need to use RND(x) function. Here you use just variable RND which is 0.

mrRothchildsjr
Posts: 6
Joined: Wed Nov 05, 2014 6:22 pm

Re: rnd() question

Post by mrRothchildsjr »

Thank you

mrRothchildsjr
Posts: 6
Joined: Wed Nov 05, 2014 6:22 pm

Re: rnd() question

Post by mrRothchildsjr »

Btw, the app is spectacular..Ty for making a great iOS programming language accessible..

User avatar
Mr. Kibernetik
Site Admin
Posts: 4786
Joined: Mon Nov 19, 2012 10:16 pm
My devices: iPhone, iPad, MacBook
Location: Russia
Flag: Russia

Re: rnd() question

Post by Mr. Kibernetik »

Thank you very much for your comment!

Dalede
Posts: 131
Joined: Fri Dec 28, 2012 4:00 pm
Location: Grass Valley, CA, USA
Contact:

Re: rnd() question

Post by Dalede »

Do not use the INT function in you code. It does not do what you think. You need to use FLOOR

Dale

Post Reply