random procedures
Author |
Message |
msimard8
|
Posted: Wed Dec 22, 2004 10:42 am Post subject: random procedures |
|
|
I dont know how detailed this question has to be.
How do you make your program call random procedures.
thanks |
|
|
|
|
![](images/spacer.gif) |
Sponsor Sponsor
![Sponsor Sponsor](templates/subSilver/images/ranks/stars_rank5.gif)
|
|
![](images/spacer.gif) |
MihaiG
![](http://compsci.ca/v3/uploads/user_avatars/2070081168483773c3dead4.png)
|
Posted: Wed Dec 22, 2004 12:29 pm Post subject: (No subject) |
|
|
procedures eh? hmmm..... i don't think its possible... because turing goes in a linear fashion it doesnt like to jump around...unlesss.... you put ur procedures in
i.e code: |
var a,b,c,pro : int
a:= 1
b:= 2
c:=3
loop
randint(pro,1,3)
if pro = a then
%insert procedure here
elsif pro = b then
%insert another procedure here
else then
%insert procedure here
end if
end loop
|
that should call up procedures randomly>?? i dunno.. i njust made it of the top of my head... sorry if there are bugs but something along those lines...we have 4 variables. the first three are going to define the procedures... and pro will choose the random procedure...
we assign a,b,c, valuies(1,2,3) we then cal apon randint function which will give pro a value of 1,2,3 we then compare var. a,b,c to pro and se which one is equal... it then is put in a if functionand calls that procedure and then loops the entire thing again... i hope this helped i think it should work correct me if i am wrong this is for turing 4.0.3x |
|
|
|
|
![](images/spacer.gif) |
Tony
![](http://wiki.compsci.ca/images/f/f4/OniTony.gif)
|
Posted: Wed Dec 22, 2004 1:30 pm Post subject: (No subject) |
|
|
you could make an array of pointers to the procedures and call one of its elements on random.
the question would be - why would you want to do that? |
|
|
|
|
![](images/spacer.gif) |
MihaiG
![](http://compsci.ca/v3/uploads/user_avatars/2070081168483773c3dead4.png)
|
Posted: Wed Dec 22, 2004 1:36 pm Post subject: (No subject) |
|
|
tony woulodn't my method work too.... its also understandble??? |
|
|
|
|
![](images/spacer.gif) |
Tony
![](http://wiki.compsci.ca/images/f/f4/OniTony.gif)
|
Posted: Wed Dec 22, 2004 1:48 pm Post subject: (No subject) |
|
|
ELCOMANDANTE wrote: tony woulodn't my method work too....
yeah, it would. I'm just suggesting alternatives. I still don't understand what he's trying to do. |
|
|
|
|
![](images/spacer.gif) |
AsianSensation
|
Posted: Wed Dec 22, 2004 4:09 pm Post subject: (No subject) |
|
|
ELCOMANDANTE wrote: woulodn't my method work too.... its also understandble???
Of course it would, but what if there were many many many many procedures? Then it wouldn't be practical. The array of pointers is the best ideal, and you can learn how to use them by learning how to use Classes. |
|
|
|
|
![](images/spacer.gif) |
|
|