Computer Science Canada Programming C, C++, Java, PHP, Ruby, Turing, VB   Username:   Password: Wiki   Blog   Search   Turing   Chat Room  Members
random number help
Author Message
Confused_PrOgRaMeR!

Posted: 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

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

Tony

Posted: 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

Tony's programming blog. DWITE - a programming contest.
recneps

Posted: 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

Posted: 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

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

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

aww maybe I should just stop replying to posts
Tony's programming blog. DWITE - a programming contest.
Mazer

Posted: 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

Posted: 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

Posted: 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.

the_short1

Posted: 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

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

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

Posted: 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

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

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

Use Rand.Int of course.

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

Posted: 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
the_short1

Posted: 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: All Posts1 Day7 Days2 Weeks1 Month3 Months6 Months1 Year Oldest FirstNewest First

Page 1 of 1  [ 14 Posts ]
 Jump to:  Select a forum  CompSci.ca ------------ - Network News - General Discussion     General Forums   -----------------   - Hello World   - Featured Poll   - Contests     Contest Forums   -----------------   - DWITE   - [FP] Contest 2006/2008   - [FP] 2005/2006 Archive   - [FP] 2004/2005 Archive   - Off Topic     Lounges   ---------   - User Lounge   - VIP Lounge     Programming -------------- - General Programming     General Programming Forums   --------------------------------   - Functional Programming   - Logical Programming   - C     C   --   - C Help   - C Tutorials   - C Submissions   - C++     C++   ----   - C++ Help   - C++ Tutorials   - C++ Submissions   - Java     Java   -----   - Java Help   - Java Tutorials   - Java Submissions   - Ruby     Ruby   -----   - Ruby Help   - Ruby Tutorials   - Ruby Submissions   - Turing     Turing   --------   - Turing Help   - Turing Tutorials   - Turing Submissions   - PHP     PHP   ----   - PHP Help   - PHP Tutorials   - PHP Submissions   - Python     Python   --------   - Python Help   - Python Tutorials   - Python Submissions   - Visual Basic and Other Basics     VB   ---   - Visual Basic Help   - Visual Basic Tutorials   - Visual Basic Submissions     Education ----------- - Student Life   Graphics and Design ----------------------- - Web Design     Web Design Forums   ---------------------   - (X)HTML Help   - (X)HTML Tutorials   - Flash MX Help   - Flash MX Tutorials   - Graphics     Graphics Forums   ------------------   - Photoshop Tutorials   - The Showroom   - 2D Graphics   - 3D Graphics     Teams ------ - dTeam Public

 Style: Appalachia blueSilver eMJay subAppalachia subBlue subCanvas subEmjay subGrey subSilver subVereor Search: