Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 random number help
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Confused_PrOgRaMeR!




PostPosted: Sun Mar 14, 2004 11:02 pm   Post subject: random number help

Hey, I was wondering how You could make a game where you have a gamepiece moving according to a dice roll or something like snakes and ladders? I really need help, its confusing me like crazy!
Thanks Surprised

Mod Edit: Post in the right section next time, Moved.
Sponsor
Sponsor
Sponsor
sponsor
Tony




PostPosted: Sun Mar 14, 2004 11:13 pm   Post subject: (No subject)

you mean like
code:

var roll:int := Rand.Int(1,6)
put "you've rolled:", roll
for i:1..roll
Draw.Box(i*10,100,i*10+10,110,blue)
delay(500)
end for

Laughing
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
recneps




PostPosted: Mon Mar 15, 2004 10:10 am   Post subject: (No subject)

Lol Tony i kept repeating that program, and i got like (honestly) 15 3's in a row. Lol, that real random work there Turing :/
the_short1




PostPosted: Mon Mar 15, 2004 12:31 pm   Post subject: (No subject)

dam... u guys are too fast at replying to these help posts... u must hound them...cuz i search me first under author and reply to any posts that are RED.... ot at least i read them...then i come here.. .and there is no need for me...
Tony




PostPosted: Mon Mar 15, 2004 1:07 pm   Post subject: (No subject)

the_short1 wrote:
and there is no need for me...


aww Smile maybe I should just stop replying to posts Laughing
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
Mazer




PostPosted: Mon Mar 15, 2004 1:21 pm   Post subject: (No subject)

recneps wrote:
Lol Tony i kept repeating that program, and i got like (honestly) 15 3's in a row. Lol, that real random work there Turing :/

That's the random seed. It isn't Turings fault, that use of the random function would give the same effect in most languages (including C++). Try putting that in a loop and running, you'll see.
(EDIT: It was explained a while back, here)
the_short1




PostPosted: Mon Mar 15, 2004 1:52 pm   Post subject: (No subject)

doesn't it get the random numbers from PIE since that doesn;t repeat and it the most acurate randomization.???? thats at least what i heard... that computers use pie for random......
Mazer




PostPosted: Mon Mar 15, 2004 2:11 pm   Post subject: (No subject)

When you say "PIE" do you by any chance mean "PI"? And how would that be used for randomization? Unless you're writing a program to actually calculate PI, then it wouldn't make a lot of sense to hold any more decimal places than 8 or so. They use the computer's time as a seed (and assume that nobody is going to run a program several times per second) to get a list of "random" numbers.
Sponsor
Sponsor
Sponsor
sponsor
the_short1




PostPosted: Mon Mar 15, 2004 3:26 pm   Post subject: (No subject)

the random seed i was told is based on 'pi'... so to find a random number it calculates 'pi' and tahts what it uses... or something like it..
Tony




PostPosted: Mon Mar 15, 2004 3:49 pm   Post subject: (No subject)

Confused pi isn't random, it's the same every time Laughing I mean sure, you could pick a random digit of pi for random value, but umm... how would you pick that digit randomly? Laughing
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
the_short1




PostPosted: Mon Mar 15, 2004 4:35 pm   Post subject: (No subject)

like using this for series of random numbers when needed.. and start at a ranom position of pie..

i dont know... that is just what i heard...

like


3.145838293438274063292348342734734289432879423764326742387423
6742398634267763477616742171671423742743217142376142372413672
4319761235451879012589074237123534789346764326754987342642136
21346243160123468012346890

being the random numbers it uses... i
Mazer




PostPosted: Mon Mar 15, 2004 5:06 pm   Post subject: (No subject)

tony wrote:
Confused pi isn't random, it's the same every time Laughing I mean sure, you could pick a random digit of pi for random value, but umm... how would you pick that digit randomly? Laughing

Use Rand.Int of course. Razz

the_short1: That's kinda like what they do. With computers, nothing is random. They just have a sequence of "random" numbers that were already generated (by some losers with a lot of time and several dice maybe), and the computer just goes through the sequence in order. Like say you had a sequence:
9, 6, 3, 8, 2, 8, 1, 5, 2, 4, ... (alot of numbers...)
The first "random" number generated would be 9, then 6, then 3, and so on. Of course the lists are pretty huge, and there's more than one sequence. So the computer uses the time as a seed to pick a sequence and go through that. This is what's going on when you run the program several times a second. When you run the program, the time is still the same and it's reading the same sequence of random numbers.

^All of that may be wrong, it's just my understanding of it. If it's wrong, look at this picture of me actually caring --> here

As for how you can get the resultant random number to be within a certain specified range, well that works by BLAH! **throws a cup of water in the_short1's face and runs away**
shorthair




PostPosted: Mon Mar 15, 2004 7:01 pm   Post subject: (No subject)

SPAM WARNING : did you notice that hte guy who started this , not only asked a really n00b question , but if you look at his name , he cant even spell programmer
Surprised Shocked Surprised
the_short1




PostPosted: Mon Mar 15, 2004 7:23 pm   Post subject: (No subject)

hm.... thats interesting.... i get programmer and programer mixed upo sometimes..
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 14 Posts ]
Jump to:   


Style:  
Search: