creating random teams?

creating random teams?

am 29.12.2006 20:34:06 von 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

Re: creating random teams?

am 29.12.2006 20:35:28 von jeff

"Jeff" wrote in message
news:q7mdnYYxst558QjYnZ2dnUVZ_sapnZ2d@adelphia.com...
> 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

Re: creating random teams?

am 29.12.2006 20:35:56 von McKirahan

"Jeff" wrote in message
news:q7mdnYYxst558QjYnZ2dnUVZ_sapnZ2d@adelphia.com...
> 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.

Re: creating random teams?

am 29.12.2006 20:43:07 von jeff

"McKirahan" wrote in message
news:5aKdnYAkNvcS8AjYnZ2dnUVZ_qK3nZ2d@comcast.com...
> "Jeff" wrote in message
> news:q7mdnYYxst558QjYnZ2dnUVZ_sapnZ2d@adelphia.com...
>> 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.
>
>
now that's a thought. I was also thinking about getting every 3rd entry, and
when it gets to eof, going back and doing it again with those who have a
t_team of 0

Re: creating random teams?

am 29.12.2006 20:59:18 von Mike Brind

"Jeff" wrote in message
news:iuSdndu4Q9tg8wjYnZ2dnUVZ_oannZ2d@adelphia.com...
>
> "McKirahan" wrote in message
> news:5aKdnYAkNvcS8AjYnZ2dnUVZ_qK3nZ2d@comcast.com...
>> "Jeff" wrote in message
>> news:q7mdnYYxst558QjYnZ2dnUVZ_sapnZ2d@adelphia.com...
>>> 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.
>>
>>
> now that's a thought. I was also thinking about getting every 3rd entry,
> and when it gets to eof, going back and doing it again with those who have
> a t_team of 0

Forget your idea. Use McKirahan's. Using the card game solitaire as an
analogy, McKirahan will finish his game by going through the deck of cards
once. You will go through the card deck seven times to accomplish the same
thing. In other words, you will be creating seven recordsets, whereas
McKirahan's approach requires just one.

--
Mike Brind

Re: creating random teams?

am 29.12.2006 21:19:35 von Dave Anderson

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()



--
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.

Re: creating random teams?

am 29.12.2006 21:20:40 von jeff

"McKirahan" wrote in message
news:5aKdnYAkNvcS8AjYnZ2dnUVZ_qK3nZ2d@comcast.com...
> "Jeff" wrote in message
> news:q7mdnYYxst558QjYnZ2dnUVZ_sapnZ2d@adelphia.com...
>> 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.
>
>
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??

Re: creating random teams?

am 29.12.2006 21:30:26 von jeff

"Dave Anderson" wrote in message
news:uanapa4KHHA.1008@TK2MSFTNGP06.phx.gbl...
> 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()
>
>
>
> --
> 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??

Re: creating random teams?

am 30.12.2006 21:28:25 von Adrienne Boswell

Gazing into my crystal ball I observed "Jeff"
writing in news:U7CdndxuAbCY5wjYnZ2dnUVZ_rOqnZ2d@adelphia.com:

>
> "Dave Anderson" wrote in message
> news:uanapa4KHHA.1008@TK2MSFTNGP06.phx.gbl...
>> 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

Re: creating random teams?

am 01.01.2007 16:00:33 von jeff

"Adrienne Boswell" wrote in message
news:Xns98A97EE3469A2arbpenyahoocom@69.28.186.121...
> Gazing into my crystal ball I observed "Jeff"
> writing in news:U7CdndxuAbCY5wjYnZ2dnUVZ_rOqnZ2d@adelphia.com:
>
>>
>> "Dave Anderson" wrote in message
>> news:uanapa4KHHA.1008@TK2MSFTNGP06.phx.gbl...
>>> 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.

Re: creating random teams?

am 01.01.2007 16:52:51 von exjxw.hannivoort

Jeff wrote on 01 jan 2007 in microsoft.public.inetserver.asp.general:

>> No, for SQL Server, NEWID() randomizes the records, so 15, 11, 8, 4,
>> 2, 9 etc.
>
> 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


--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)

Re: creating random teams?

am 01.01.2007 17:46:26 von jeff

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

Happy New Year!!




"Evertjan." wrote in message
news:Xns98ABABB99970Aeejj99@194.109.133.242...
> Jeff wrote on 01 jan 2007 in microsoft.public.inetserver.asp.general:
>
>>> No, for SQL Server, NEWID() randomizes the records, so 15, 11, 8, 4,
>>> 2, 9 etc.
>>
>> 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
>
>
> --
> Evertjan.
> The Netherlands.
> (Please change the x'es to dots in my emailaddress)