473,385 Members | 1,192 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

creating random teams?

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
Dec 29 '06 #1
11 1720

"Jeff" <gi*****@adelphia.netwrote in message
news:q7******************************@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
Dec 29 '06 #2
"Jeff" <gi*****@adelphia.netwrote in message
news:q7******************************@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.
Dec 29 '06 #3

"McKirahan" <Ne**@McKirahan.comwrote in message
news:5a******************************@comcast.com. ..
"Jeff" <gi*****@adelphia.netwrote in message
news:q7******************************@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

Dec 29 '06 #4

"Jeff" <gi*****@adelphia.netwrote in message
news:iu******************************@adelphia.com ...
>
"McKirahan" <Ne**@McKirahan.comwrote in message
news:5a******************************@comcast.com. ..
>"Jeff" <gi*****@adelphia.netwrote in message
news:q7******************************@adelphia.co m...
>>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
Dec 29 '06 #5

"McKirahan" <Ne**@McKirahan.comwrote in message
news:5a******************************@comcast.com. ..
"Jeff" <gi*****@adelphia.netwrote in message
news:q7******************************@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??
Dec 29 '06 #6
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.
Dec 29 '06 #7

"Dave Anderson" <NY**********@spammotel.comwrote in message
news:ua**************@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??
Dec 29 '06 #8
Gazing into my crystal ball I observed "Jeff" <gi*****@adelphia.net>
writing in news:U7******************************@adelphia.com :
>
"Dave Anderson" <NY**********@spammotel.comwrote in message
news:ua**************@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

Dec 30 '06 #9

"Adrienne Boswell" <ar****@yahoo.comwrote in message
news:Xn****************************@69.28.186.121. ..
Gazing into my crystal ball I observed "Jeff" <gi*****@adelphia.net>
writing in news:U7******************************@adelphia.com :
>>
"Dave Anderson" <NY**********@spammotel.comwrote in message
news:ua**************@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.
Jan 1 '07 #10
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)
Jan 1 '07 #11
thanks for that.
i got it to work thanks to you all

Happy New Year!!


"Evertjan." <ex**************@interxnl.netwrote in message
news:Xn********************@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)

Jan 1 '07 #12

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Code_Dark | last post by:
Hi, sorry to bore you with my newbie questions, but I _am_ a newbie so.. right. Anyway, I was working out a "number guessing game", which works fine, except I wanted to make the number a random...
7
by: msnews.microsoft.com | last post by:
Hello everyone! I would like to know about who "can" and "should" be included in the Software Development Teams for small and startup companies. Consider this scenario: Three persons wish to...
16
by: a | last post by:
We are writing an app that assigns people to teams based on their curent score. Teams are 8 people, there are 2 teams. (i would like it to be flexible, but this is a start). I need an algorithm...
15
by: Steven Macintyre | last post by:
Hi all, I need to retrieve an integer from within a range ... this works ... below is my out puts ... it just does not seem so random ... Is there perhaps a suggestion out there to create a...
4
by: tshad | last post by:
I am trying to set up an Image authorization where you type in the value that is in a picture to log on to our site. I found a program that is supposed to do it, but it doesn't seem to work. ...
1
by: Rune Jacobsen | last post by:
Hi, Since noone replied to my other post, I have simplified my spec a bit in the hope that I can adequately explain what I am trying to achieve. For those interested, I have created a mockup...
6
by: Stuartzz | last post by:
I apologise if this is not the correct forum to post my query. I have 27 subteams, of varying size typically 3-10 people, totalling 207 people. I want to group together subteams to have 10 teams of...
24
by: Diwa | last post by:
Hi All, This is not a C++ technical question, hence this is an off-topic post. But it is C++ related and posted only to this group. Suppose, today a building like Empire State building or...
6
by: hinksta | last post by:
I'm trying to build a football leage table taking it's content from a results database, CREATE TABLE conference ( id int NOT NULL auto_increment primary key, season VARCHAR(50) NOT NULL, ...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.