Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 8 of 8
  1. #1
    New Coder
    Join Date
    Jul 2011
    Posts
    52
    Thanks
    4
    Thanked 0 Times in 0 Posts

    Help - Generating league matches

    Hello.
    I am building a script that when I run it will generate all my league matches.
    I have 16 players.
    I want to do that when I run this script it will generate in a database table all needed information.
    the table:
    Player1 | Player2 | Round

    Example:

    1 | 2 | 1
    3 | 4 | 1
    5 | 6 | 1
    ..
    1 | 3 | 2
    2 | 4 | 2
    3 | 5 | 2
    ..
    all availaboe options to make each player fight each other from player 1 to player 16.

    I was trying to solve it all night and couldnt find a solution. Thanks for help
    Need domain? Buy Cheap Domain at Rapid Host :)

  • #2
    New Coder
    Join Date
    Jul 2011
    Posts
    52
    Thanks
    4
    Thanked 0 Times in 0 Posts
    Any help? Please.
    Another explenation:

    I want to make a script that will generate all possible matches from 1 to 16.
    More info: I have 16 players in a tournament. I am developing league system and I need a script that will generate all the possible matches by rounds.
    All possible matches - I mean that Player1 vs player2, player 3 vs player 4, players 1 vs player 3, player 16 vs 15, player 15 vs 5 etc...........
    My table:
    Playe1 | Player2| Round

    In round = 1 it should be all league matches for all players 1-16,
    in round = 2 the same, just a match that already was in round = 1 can't be in round = 2
    In round = 3 the same, just match that already was in round =1, round = 2 can't be in round = 3
    .. etc untill all possible combinations are done

    I am trying to figure it out for a while and couldnt find a solution. Any help will be appreciated!
    Need domain? Buy Cheap Domain at Rapid Host :)

  • #3
    Senior Coder
    Join Date
    Feb 2011
    Location
    Your Monitor
    Posts
    4,091
    Thanks
    51
    Thanked 506 Times in 493 Posts
    What you're asking is essentially help to build an entire site from what I can understand - people are busy with their own projects.

    If you have a specific problem with your code then tell us and we can help you fix it but not many people here will help you build a site from scratch for free.

    Quote Originally Posted by topdown.me View Post
    .. etc untill all possible combinations are done
    Perhaps listing all the possible combinations would be a good start towards getting help because otherwise it's yet another thing that someone else needs to do for you. If you can list all the possible combinations someone might translate that into code for you. It doesn't help that you're also expecting us to understand how these rounds work without even telling us what sport it is - I know nothing about most sports rounds so that instantly rules me out!

    You clearly have an idea but don't seem to be able to work out the steps involved and seem to want someone else to do all the hard work for you. Unfortunately that won't happen here - you need to come up with your logic / site design and then come back with little pieces of the puzzle you need solving. Have a look at the other threads that have lots of replies and you will see that they have a specific problem that they need fixing - those are the threads that get answers
    Last edited by tangoforce; 06-14-2013 at 03:21 PM.
    My helpful sig is on vacation trying to loose some weight. It got a bit fat and caused a few problems but it will be back at some point!

  • #4
    New Coder
    Join Date
    Jul 2011
    Posts
    52
    Thanks
    4
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by tangoforce View Post
    What you're asking is essentially help to build an entire site from what I can understand - people are busy with their own projects.

    If you have a specific problem with your code then tell us and we can help you fix it but not many people here will help you build a site from scratch for free.



    Perhaps listing all the possible combinations would be a good start towards getting help because otherwise it's yet another thing that someone else needs to do for you. If you can list all the possible combinations someone might translate that into code for you. It doesn't help that you're also expecting us to understand how these rounds work without even telling us what sport it is - I know nothing about most sports rounds so that instantly rules me out!

    You clearly have an idea but don't seem to be able to work out the steps involved and seem to want someone else to do all the hard work for you. Unfortunately that won't happen here - you need to come up with your logic / site design and then come back with little pieces of the puzzle you need solving. Have a look at the other threads that have lots of replies and you will see that they have a specific problem that they need fixing - those are the threads that get answers
    whot? How did you get to this conclusion? This is just a small piece from my website. I'm running a browser based game with alot of features, and I want to impelement a league system.
    What I'm asking you is that I can't figure out the logic of how to create the script and how to loop all the possible combinationsr from 1 to 16..
    Need domain? Buy Cheap Domain at Rapid Host :)

  • #5
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,979
    Thanks
    4
    Thanked 2,659 Times in 2,628 Posts
    1 - 16 is a simple matter:
    PHP Code:
    $aAvailable range(116); // this can be an array from a db
    $aPairs = array();

    $iAvailable count($aAvailable);

    for (
    $i 0$i $iAvailable; ++$i)
    {
        for (
    $j $i$j $iAvailable; ++$j)
        {
            if (
    $i != $j)
            {
                
    $aPairs[] = array($aAvailable[$i], $aAvailable[$j]);
            }
        }
    }

    print_r($aPairs); 
    Which will return a list of. . . 120 pairs of x,y. That should be all combinations covered from 1 - 16 (in this example, you can query a dataset BUT it will need to be a numerical array to work with the loops [since I was too lazy to use a while :P]), without repeating the combinations. So 1, 3 will exist, but 3, 1 will not. If order doesn't matter, and you can have both 1, 3, and 3, 1, simply change the for ($j = $i to $j = 0. That would result in, uhh, 240 matches.

    Edit:
    oic, doing it in "rounds" is also far more complex. Since you effectively shuffle the numbers around. Should be a relatively easy change overall to gather though, I'll get back.
    Last edited by Fou-Lu; 06-14-2013 at 09:28 PM.
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 

  • Users who have thanked Fou-Lu for this post:

    topdown.me (06-15-2013)

  • #6
    Master Coder mlseim's Avatar
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,389
    Thanks
    8
    Thanked 1,077 Times in 1,068 Posts
    Last edited by mlseim; 06-14-2013 at 09:56 PM.

  • Users who have thanked mlseim for this post:

    topdown.me (06-15-2013)

  • #7
    Senior Coder
    Join Date
    Feb 2011
    Location
    Your Monitor
    Posts
    4,091
    Thanks
    51
    Thanked 506 Times in 493 Posts
    Quote Originally Posted by topdown.me View Post
    This is just a small piece from my website.

    What I'm asking you is that I can't figure out the logic of how to create the script and how to loop all the possible combinationsr from 1 to 16..
    And now you've mentioned that, you get two more people reply

    See what I was getting at?
    My helpful sig is on vacation trying to loose some weight. It got a bit fat and caused a few problems but it will be back at some point!

  • #8
    New Coder
    Join Date
    Jul 2011
    Posts
    52
    Thanks
    4
    Thanked 0 Times in 0 Posts
    Thank you very much.
    I found http://www.ultramegatech.com/2010/05...ent-scheduler/ to be very useful.
    Need domain? Buy Cheap Domain at Rapid Host :)


  •  

    Posting Permissions

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