Tournament Help
Author 
Message 
l0tt0

Posted: Thu Dec 04, 2003 10:56 pm Post subject: Tournament Help 


Hey Everyone, I made this tournament code for my site to find out who's where in the tournament. I haven't learned how to do tony's proc to check to make sure two numbers are the same so i just used the big exit when line. What i want to know is if there's anyway to amke it run faster besides a better system of making sure no matches are the same?
Thanks.
code: 
var l: array 1..8 of int % First Set Of Numbers
var r: array 1..8 of int % Second Set Of Numbers
var n: array 1..16 of string % Name Of People Competing In Tournament
for x: 1..16 % Getting The Names of People In The Tournament
put "Please enter a name in the tournament(",x,")"
get n(x)
end for
loop
cls
for z: 1..8
l(z):=Rand.Int(1,8) % First Set Of Random Numbers
r(z):=Rand.Int(1,8) % Second Set Of Random Numbers
end for
exit when l(1) not=l(2) and l(1) not=l(3) and l(1) not=l(4) and l(1) not=l(5) and l(1) not=l(6) and l(1) not=l(7) and l(1) not=l(8)
and l(2) not=l(3) and l(2) not=l(4) and l(2) not=l(5) and l(2) not=l(6) and l(2) not=l(7) and l(2) not=l(8)
and l(3) not=l(4) and l(3) not=l(5) and l(3) not=l(6) and l(3) not=l(7) and l(3) not=l(8)
and l(4) not=l(5) and l(4) not=l(6) and l(4) not=l(7) and l(4) not=l(8)
and l(5) not=l(6) and l(5) not=l(7) and l(5) not=l(8)
and l(6) not=l(7) and l(6) not=l(8)
and l(7) not=l(8)
and r(1) not=r(2) and r(1) not=r(3) and r(1) not=r(4) and r(1) not=r(5) and r(1) not=r(6) and r(1) not=r(7) and r(1) not=r(8)
and r(2) not=r(3) and r(2) not=r(4) and r(2) not=r(5) and r(2) not=r(6) and r(2) not=r(7) and r(2) not=r(8)
and r(3) not=r(4) and r(3) not=r(5) and r(3) not=r(6) and r(3) not=r(7) and r(3) not=r(8)
and r(4) not=r(5) and r(4) not=r(6) and r(4) not=r(7) and r(4) not=r(8)
and r(5) not=r(6) and r(5) not=r(7) and r(5) not=r(8)
and r(6) not=r(7) and r(6) not=r(8)
and r(7) not=r(8)
end loop
for a: 1..8
put n(a),"",l(a) % Displays First 18 Names With Number
end for
for b: 1..8
put n(b+8),"",r(b) % Displays Second Set of Names With Number
end for







Sponsor Sponsor



Tony

Posted: Thu Dec 04, 2003 11:53 pm Post subject: (No subject) 


wow man... could you do yourself a favor and take Data Managment in grade 12?
When generating 8 random numbers (from 1 to 8), what are the chances of them to generate an unique list?
well chances of first to not repeat are 1/1
second  7/8
third  6/8
...
eighth  1/8...
multiply all those numbers together... you get 0.0025
they translate into 1:400 odds of you generating a unique list 
Tony's programming blog. DWITE  a programming contest. 




l0tt0

Posted: Sun Dec 07, 2003 11:59 pm Post subject: (No subject) 


huh?
im only in grade 10...but i think i understand what u said...almost
taht there's practically no chance of gettin those numbers...? 





DanShadow

Posted: Mon Dec 08, 2003 12:06 am Post subject: .. 


ok....is this code s upposed to go through long random pointless (algorithyms) to find 1 person from each list to go against each other in a tournament? If so, its so much easier that that.
code: 
var tournlist_1,tournlist_2:array 1..20 of int
var tourn_num1,tourn_num2:int:=1
randint(tourn_num1,1,20)
randint(tourn_num2,1,20)
put tournlist_1(tourn_num1)
put "faces off against"
put tournlist_2(tourn_num2)

Just ask for the names of the tournament people under the variables.
Hopefully I understood what your program was doing. (Maybe make a couple comments?) 





AsianSensation

Posted: Mon Dec 08, 2003 12:09 am Post subject: (No subject) 


but with your code, a person could go against him or herself.
Also, in a tournament, I think you only play each person once. Or something like that, so a bit of math is involved. just use the stuff you learned in data management. 





Tony

Posted: Mon Dec 08, 2003 10:09 am Post subject: (No subject) 


the guy is not in data managment, he's in grade 10
anyways, here's the link to the source code for that random list generator. Try to understand how it works. 
Tony's programming blog. DWITE  a programming contest. 




DanShadow

Posted: Mon Dec 08, 2003 12:05 pm Post subject: .. 


Ok, just make a new array...like for people who already played. Like.....
code: 
var tournie_used_people:array 1..40 of int
%Do the script that makes a random name, and check if its not fighting itself...
%Then check this array to see if names have been picked, if they have, redo randint








