creating random teams?

Discussion in 'ASP General' started by Jeff, Dec 29, 2006.

  1. Jeff

    Jeff Guest

    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
    Jeff, Dec 29, 2006
    #1
    1. Advertising

  2. Jeff

    Jeff Guest

    "Jeff" <> wrote in message
    news:...
    > 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
    Jeff, Dec 29, 2006
    #2
    1. Advertising

  3. Jeff

    McKirahan Guest

    "Jeff" <> wrote in message
    news:...
    > 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.
    McKirahan, Dec 29, 2006
    #3
  4. 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.
    Dave Anderson, Dec 29, 2006
    #4
  5. Jeff

    Jeff Guest

    "McKirahan" <> wrote in message
    news:...
    > "Jeff" <> wrote in message
    > news:...
    >> 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??
    Jeff, Dec 29, 2006
    #5
  6. Jeff

    Jeff Guest

    "Dave Anderson" <> wrote in message
    news:...
    > 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??
    Jeff, Dec 29, 2006
    #6
  7. Gazing into my crystal ball I observed "Jeff" <>
    writing in news::

    >
    > "Dave Anderson" <> wrote in message
    > news:...
    >> 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
    Adrienne Boswell, Dec 30, 2006
    #7
  8. Jeff

    Jeff Guest

    "Adrienne Boswell" <> wrote in message
    news:Xns98A97EE3469A2arbpenyahoocom@69.28.186.121...
    > Gazing into my crystal ball I observed "Jeff" <>
    > writing in news::
    >
    >>
    >> "Dave Anderson" <> wrote in message
    >> news:...
    >>> 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.
    Jeff, Jan 1, 2007
    #8
  9. Jeff

    Evertjan. Guest

    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)
    Evertjan., Jan 1, 2007
    #9
  10. Jeff

    Jeff Guest

    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)
    Jeff, Jan 1, 2007
    #10
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. zcraven
    Replies:
    3
    Views:
    2,567
    Bruno Grieder
    Oct 29, 2004
  2. Replies:
    0
    Views:
    316
  3. Diwa
    Replies:
    24
    Views:
    750
  4. John Griffiths

    teams -> members -> users

    John Griffiths, Dec 16, 2007, in forum: Ruby
    Replies:
    10
    Views:
    178
    Todd Benson
    Dec 17, 2007
  5. Daniel Moore

    [QUIZ] IRC Teams (#221)

    Daniel Moore, Oct 16, 2009, in forum: Ruby
    Replies:
    1
    Views:
    134
    Martin DeMello
    Oct 19, 2009
Loading...

Share This Page