CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2

Thread: Game Schedule, logic

  1. #1
    Join Date
    Feb 2012

    Game Schedule, logic


    I know I can't be the only game scheduler in the world with this problem...

    I need to write a tool that schedules games for x number of weeks with x number of teams that ensures every team plays each other (if possible).

    The basics of the functionality is this:

    * There can be an even or odd number of teams, if odd there will of course be a "bye" week where one team is not playing (buy could be considered a team when doing the algorithm).

    * The number of weeks can be either even or odd, basically the algorithm should just run until the number of weeks run out.

    * The rotation should be so that every team plays every team but never itself (if number of weeks permits)

    Basically for 4 teams the result would look like this:


    A vs B
    C vs D


    A vs C
    B vs D


    A vs D
    B vs C

    I would like the code to be able to handle the number of games as input, but honestly if the rotation is solved, I can limit the number of games myself.

    I do appreciate any help or direction I can get.


  2. #2
    DataMiser is offline Super Moderator Power Poster
    Join Date
    Jul 2008

    Re: Game Schedule, logic

    Off the top of my head I think I would use a random number generator. I would have a list of teams and for each team I would store a list of teams each team has played/scheduled so far another list that would hold the teams not yet scheduled for the current week. The random number generator would be used to pick from one of the remaining teams making sure it is not the current team then removing the team from the teams remaining for the week list and adding the team to the teams played/scheduled list.

    Should not be that hard but will require a little thought.
    Always use [code][/code] tags when posting code.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Windows Mobile Development Center

Click Here to Expand Forum to Full Width

On-Demand Webinars (sponsored)