View Single Post
Old 11-15-2012, 03:54 PM   PM User | #30
Fou-Lu
God Emperor


 
Fou-Lu's Avatar
 
Join Date: Sep 2002
Location: Saskatoon, Saskatchewan
Posts: 15,661
Thanks: 4
Thanked 2,452 Times in 2,421 Posts
Fou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to all
Start times at this point is irrelevant. Once you get the array of data you need split up properly, you can schedule time as you need based on ordered array.
You'll need to have a full example. With 12 teams, 60 games is insufficient for every team to play every other team (you need 66 games for that). These are where your rules cannot be calculated mathematically. 8 teams require 28, 9 teams require 36, 10 45, 11 55, 12 66. Coming up with the combinations is the easy part. That's a simple:
PHP Code:
function teamPlayCombinations(array $aTeams)
{
    
$aResult = array();
    
$iTeams count($aTeams);
    for (
$i 0$i $iTeams; ++$i)
    {
        for (
$j $iTeams 1$j $i; --$j)
        {
            
$aResult[] = array($aTeams[$i], $aTeams[$j]);
        }
    }
    return 
$aResult;

That would give all the possible combinations where order is not important (1 plays 2 is the same as 2 plays 1).
But this is absolutely useless to you if at 8 @ 40 games gives you 12 too many, and 12 @ 60 games gives you 6 short. Scheduling so one team only plays once per week isn't a super easy task, but that just takes some conditional checking to see if they are scheduled to play already.
But like I've been saying, until you specifically resolve your ruleset to dictate how you apply repeated plays (in the case of 8 @ 40) or whom doesn't play (in the case of 12 @ 60), then you cannot properly populate this data.
Fou-Lu is offline   Reply With Quote