creating random teams?

J

Jeff

het gang. Happy Holidays and stuff.

Here is what I am wanting to do, but need some guidance as hwo to start in
the right direction.

using sql db on ms server

i have players sign up for a tourney. easy

when the tourney begins, i want it to set teams. i have a number in the db
that tells how many on a team. ivarnum =

now, i need to script to count the number registered.. easy

then set by dividing by the preset variable will tell how many teams there
will be..

so say 21 players registered, and the ivarnum = 3, thus giving that there
will be 7 teams.

now i need to assign by a random script, who is on what team, so that 3
people are on each team.

i have a field in the db called t_team, this is an integer, so it will get
assigned a number 1-7, and that will be taht persons team for the tourney.

so how can i assign this random number between 1 and 7 (in this case) and
once 3 are choosen with the same number, it won't use it again?

does this make sense of what i want?/

any help would be appreciated.

Bam
 
J

Jeff

Jeff said:
het gang. Happy Holidays and stuff.

Here is what I am wanting to do, but need some guidance as hwo to start in
the right direction.

using sql db on ms server

i have players sign up for a tourney. easy

when the tourney begins, i want it to set teams. i have a number in the db
that tells how many on a team. ivarnum =

now, i need to script to count the number registered.. easy

then set by dividing by the preset variable will tell how many teams there
will be..

so say 21 players registered, and the ivarnum = 3, thus giving that there
will be 7 teams.

now i need to assign by a random script, who is on what team, so that 3
people are on each team.

i have a field in the db called t_team, this is an integer, so it will get
assigned a number 1-7, and that will be taht persons team for the tourney.

so how can i assign this random number between 1 and 7 (in this case) and
once 3 are choosen with the same number, it won't use it again?

does this make sense of what i want?/

any help would be appreciated.

Bam
I should add that the name field is t_username, in case that is needed in
the help
 
M

McKirahan

Jeff said:
het gang. Happy Holidays and stuff.

Here is what I am wanting to do, but need some guidance as hwo to start in
the right direction.

using sql db on ms server

i have players sign up for a tourney. easy

when the tourney begins, i want it to set teams. i have a number in the db
that tells how many on a team. ivarnum =

now, i need to script to count the number registered.. easy

then set by dividing by the preset variable will tell how many teams there
will be..

so say 21 players registered, and the ivarnum = 3, thus giving that there
will be 7 teams.

now i need to assign by a random script, who is on what team, so that 3
people are on each team.

i have a field in the db called t_team, this is an integer, so it will get
assigned a number 1-7, and that will be taht persons team for the tourney.

so how can i assign this random number between 1 and 7 (in this case) and
once 3 are choosen with the same number, it won't use it again?

does this make sense of what i want?/

any help would be appreciated.

Bam

An alternative might be to sort the players by, say,
the second character in their last name and then use
three at a time to make a team.
 
D

Dave Anderson

Jeff said:
...using sql db on ms server...

...now i need to assign by a random script, who is on what team,
so that 3 people are on each team...

In SQL Server, you can always randomize any recordset with this clause:

ORDER BY NEWID()

So, select all players with that clause and assign the first three to team
1, the next three to team 2, and so on.

SELECT * FROM [your table of registrants]
ORDER BY NEWID()
 
J

Jeff

McKirahan said:
An alternative might be to sort the players by, say,
the second character in their last name and then use
three at a time to make a team.
roger that. i see where you are going with this.

so i could create a case then. and depending on how many teams there will
be, is how many it will grab from the sort??

is that what i am understanding here??
 
J

Jeff

Dave Anderson said:
Jeff said:
...using sql db on ms server...

...now i need to assign by a random script, who is on what team,
so that 3 people are on each team...

In SQL Server, you can always randomize any recordset with this clause:

ORDER BY NEWID()

So, select all players with that clause and assign the first three to team
1, the next three to team 2, and so on.

SELECT * FROM [your table of registrants]
ORDER BY NEWID()



--
Dave Anderson

Unsolicited commercial email will be read at a cost of $500 per message.
Use of this email address implies consent to these terms.
but using that, it would set the teams by the order they signed up??
 
A

Adrienne Boswell

Dave Anderson said:
Jeff said:
...using sql db on ms server...

...now i need to assign by a random script, who is on what team,
so that 3 people are on each team...

In SQL Server, you can always randomize any recordset with this
clause:

ORDER BY NEWID()

So, select all players with that clause and assign the first three to
team 1, the next three to team 2, and so on.

SELECT * FROM [your table of registrants]
ORDER BY NEWID()
but using that, it would set the teams by the order they signed up??

No, for SQL Server, NEWID() randomizes the records, so 15, 11, 8, 4, 2,
9 etc.
 
J

Jeff

Adrienne Boswell said:
Dave Anderson said:
Jeff wrote:
...using sql db on ms server...

...now i need to assign by a random script, who is on what team,
so that 3 people are on each team...

In SQL Server, you can always randomize any recordset with this
clause:

ORDER BY NEWID()

So, select all players with that clause and assign the first three to
team 1, the next three to team 2, and so on.

SELECT * FROM [your table of registrants]
ORDER BY NEWID()
but using that, it would set the teams by the order they signed up??

No, for SQL Server, NEWID() randomizes the records, so 15, 11, 8, 4, 2,
9 etc.


--
Adrienne Boswell at Home
Arbpen Web Site Design Services
http://www.cavalcade-of-coding.info
Please respond to the group so others can share

Ok, I understand that.
Now, if there are say... 48 members, would I write a case to determine how
many teams to create?

because the number of teams would probably change each time the script is
run.

sorry for my ignorance, but something things take a little longer to pound
in.
 
E

Evertjan.

Jeff wrote on 01 jan 2007 in microsoft.public.inetserver.asp.general:
Ok, I understand that.
Now, if there are say... 48 members, would I write a case to determine
how many teams to create?

because the number of teams would probably change each time the script
is run.

sorry for my ignorance, but something things take a little longer to
pound in.

Simply fill team 1 with the first 3 members from the random db results,
team 2 with the second 3 members,
etc.

You will end up with a number of teams.
The last team could have less than 3 members.
What you do with those members is up to your definition.

[48 members will fill exactly 16 teams.]

Just straightforward programming, meseems.

You could give each member an extra field in his record,
named 'teamNumberMatchJan2007'.
[and build and maintain other teams in other matchesand keep those on
record at the same time]

VBS-ish pseudocode:

..........
ORDER BY NEWID()

n=1 ' counter
t=1 ' teamcounter
do until end of table
field["teamNumberMatchJan2007"] = t
n = n + 1
if n > 3 then n = 1 : t = t + 1
nextRecord
loop

you could then, if you like, give the team members [5 here] personal
points based on their team [number 12 here] performance:

UPDATE membTbl
SET points = points + 5
WHERE teamNumberMatchJan2007 = 12
 
J

Jeff

thanks for that.
i got it to work thanks to you all

Happy New Year!!




Evertjan. said:
Jeff wrote on 01 jan 2007 in microsoft.public.inetserver.asp.general:
Ok, I understand that.
Now, if there are say... 48 members, would I write a case to determine
how many teams to create?

because the number of teams would probably change each time the script
is run.

sorry for my ignorance, but something things take a little longer to
pound in.

Simply fill team 1 with the first 3 members from the random db results,
team 2 with the second 3 members,
etc.

You will end up with a number of teams.
The last team could have less than 3 members.
What you do with those members is up to your definition.

[48 members will fill exactly 16 teams.]

Just straightforward programming, meseems.

You could give each member an extra field in his record,
named 'teamNumberMatchJan2007'.
[and build and maintain other teams in other matchesand keep those on
record at the same time]

VBS-ish pseudocode:

.........
ORDER BY NEWID()

n=1 ' counter
t=1 ' teamcounter
do until end of table
field["teamNumberMatchJan2007"] = t
n = n + 1
if n > 3 then n = 1 : t = t + 1
nextRecord
loop

you could then, if you like, give the team members [5 here] personal
points based on their team [number 12 here] performance:

UPDATE membTbl
SET points = points + 5
WHERE teamNumberMatchJan2007 = 12
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top