
-----------------------------------
Confused_PrOgRaMeR!
Sun Mar 14, 2004 11:02 pm

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  :o

Mod Edit: Post in the right section next time, Moved.

-----------------------------------
Tony
Sun Mar 14, 2004 11:13 pm


-----------------------------------
you mean like

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

 :lol:

-----------------------------------
recneps
Mon Mar 15, 2004 10:10 am


-----------------------------------
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
Mon Mar 15, 2004 12:31 pm


-----------------------------------
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
Mon Mar 15, 2004 1:07 pm


-----------------------------------
and there is no need for me...

aww :) maybe I should just stop replying to posts :lol:

-----------------------------------
Mazer
Mon Mar 15, 2004 1:21 pm


-----------------------------------
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, [url=http://www.compsci.ca/v2/viewtopic.php?t=1632&highlight=random+seed]here)

-----------------------------------
the_short1
Mon Mar 15, 2004 1:52 pm


-----------------------------------
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
Mon Mar 15, 2004 2:11 pm


-----------------------------------
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
Mon Mar 15, 2004 3:26 pm


-----------------------------------
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
Mon Mar 15, 2004 3:49 pm


-----------------------------------
:? pi isn't random, it's the same every time :lol: I mean sure, you could pick a random digit of pi for random value, but umm... how would you pick that digit randomly? :lol:

-----------------------------------
the_short1
Mon Mar 15, 2004 4:35 pm


-----------------------------------
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
Mon Mar 15, 2004 5:06 pm


-----------------------------------
:? pi isn't random, it's the same every time :lol: I mean sure, you could pick a random digit of pi for random value, but umm... how would you pick that digit randomly? :lol:
Use Rand.Int of course.  :P 

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 --> BLAH! **throws a cup of water in the_short1's face and runs away**

-----------------------------------
shorthair
Mon Mar 15, 2004 7:01 pm


-----------------------------------
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
 :o  :shock:  :o

-----------------------------------
the_short1
Mon Mar 15, 2004 7:23 pm


-----------------------------------
hm.... thats interesting.... i get programmer and programer mixed upo sometimes..
