Hello and welcome to our community! Is this your first visit?
Enjoy an ad free experience by logging in. Not a member yet? Register.

# Thread: Help - Generating league matches

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

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!

• What you're asking is essentially help to build an entire site from what I can understand - people are busy with their own projects.

Originally Posted by topdown.me
.. 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

• Originally Posted by tangoforce
What you're asking is essentially help to build an entire site from what I can understand - people are busy with their own projects.

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

• 1 - 16 is a simple matter:
PHP Code:
``` \$aAvailable = range(1, 16); // 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.

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

topdown.me (06-15-2013)

• ## Users who have thanked mlseim for this post:

topdown.me (06-15-2013)

• Originally Posted by topdown.me
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?

• Thank you very much.
I found http://www.ultramegatech.com/2010/05...ent-scheduler/ to be very useful.

•

#### Posting Permissions

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