12-17-2005, 03:59 PM
Can anybody help me make this little program, i know the basics but need help with the math.
i want a random generator to choose who plays who
i want a random generator to choose who plays who
Quote:Can anybody help me make this little program, i know the basics but need help with the math.The points made by yetifoot about different football seasons are true, but you did say that you want to choose teams at random. So here's some code to get you started with the random selection of two teams each time. Let's assume that you have a total of 16 teams. I added a little test to make sure that the second random team number is not equal to the first.
i want a random generator to choose who plays who
DECLARE FUNCTION RandInt% (lower, Upper)
RANDOMIZE TIMER
dim team1 as integer
dim team2 as integer
const numteams = 16
team1 = Randint% (1,numteams)
do
team2 = Randint% (1,numteams)
loop while team2=team1
'....... the rest of your code goes here.......
END
' =============================== RandInt% ===================================
' Returns a random integer greater than or equal to the Lower parameter
' and less than or equal to the Upper parameter.
' ============================================================================
'
FUNCTION RandInt% (lower, Upper) STATIC
RandInt% = INT(RND * (Upper - lower + 1)) + lower
END FUNCTION