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

# Thread: Schedule function help needed

1. Originally Posted by Fou-Lu
Yes, I'm aware of what you want to do. What I'm saying is with 8 teams you cannot play a total of 40 games without partial repetition. So my question is still how to deal with which combinations are chosen for repetition. So I can only write combinations which apply to 7 games per team; that is one team plays every other team once and only once (28 games). If you played 56 total games (repetition allowed), then you could do it evenly with the 8, but not with 40.
The only way to get to the 40 with 8 teams really is to make it so every team only plays a total of 5 games. But again, that creates a problem since you still need to decide which two teams each team will not play against (each team needs to play 7 in order to play completely against each other).

as I said teams always play more then once, that's ok, this is not a round robbin or
something its just a basic 10 game (Sunday) schedule that's all, the ideal function would
know how to use byes to get as close as possible to perfect.

when I was coaching 4th and 5th graders we had a lot of teams like 20, now with the 8th
graders next spring, I think the max number of teams would be around 10 or 12. maybe I
will have to limit the amount of teams to work with the function or something, but I would
hate to do that if I don't have too.

I see scheduling like this being done all the time not only based on amount of teams and
weeks to play, but the start times as well, not to mention home and away, Boy when I
first started on this I had no idea how hard it would be.

Sonny

2. What is a byes? I had assumed it was a term you used to simply remove an odd number, but this makes it sound more like a technical term.
Its not a hard problem, its simply a couple of loops. But like I said, you simply don't conform to standard mathematics, so you cannot rely directly on combination calculations. With 8 teams you'll simply end up with either a remainder of 12 or a shortage of 16 games to play. You just can't divide into this number to end up with an even result; there will be overlap but you need to dictate the rules to calculate the overlap.

3. Originally Posted by Fou-Lu
What is a byes? I had assumed it was a term you used to simply remove an odd number, but this makes it sound more like a technical term.
Its not a hard problem, its simply a couple of loops. But like I said, you simply don't conform to standard mathematics, so you cannot rely directly on combination calculations. With 8 teams you'll simply end up with either a remainder of 12 or a shortage of 16 games to play. You just can't divide into this number to end up with an even result; there will be overlap but you need to dictate the rules to calculate the overlap.
a bye is if no team has a opponent for the week they do not play that's all
team1 vs bye
tean2 vs team7 ,,,

here is something that is really close to what I need to do this creates a team schedule
and works great for 8 teams, problem is it errors with 10 teams and over and has
no bye. it also does not provide amount of games to play

I found something that creates a scheduleand works great for
8 teams, problem is it errors with 10 and over teams and has
no bye.

phpkode/scripts/item/team-schedule-maker

Sonny

4. Does a game against a 'bye' qualify against the total games played?

5. Originally Posted by Fou-Lu
Does a game against a 'bye' qualify against the total games played?

Fou its just a basic 10 week schedule for a youth soccer league
teams play once a week on Sunday 9am, 11am, 1pm and 3pm for
10 weeks that would be based on 8 teams of course. which is low

Yes a bye would count towards a game played since 10 weeks is a season
no matter what, that was a good question, I never thought about that. rain
outs are always made up, and if necessary I always try my best for even teams
one time I had 11 player roster's to get-even teams. that was cutting it close
because you know there's always somebody not showing.

Thanks for thinking about me this mourning.

Sonny

6. See now we're getting somewhere. Does a team vs bye require indication of such? If not, then I'd suggest simply null padding the string up to the required number of games and weeks.
I'll have to write this in java so that I can use a debugger since I'm not at home, and then convert it to PHP.

7. Originally Posted by Fou-Lu
See now we're getting somewhere. Does a team vs bye require indication of such? If not, then I'd suggest simply null padding the string up to the required number of games and weeks.
I'll have to write this in java so that I can use a debugger since I'm not at home, and then convert it to PHP.
I think its best to show the word bye when its applied
Team7 vs bye
team4 vs team2 etc

Thanks
Sonny

8. Can bye be randomly assigned? Since the remainder is fractional at 1.5, it means some teams will need to play bye multiple times instead of only once.

9. Originally Posted by Fou-Lu
Can bye be randomly assigned? Since the remainder is fractional at 1.5, it means some teams will need to play bye multiple times instead of only once.
Yes as long as its fair as possible to all teams, I will do my best to get even teams
but if one team winds up with one more bye then another I will take care of that manually
same with start times one team might get more of a preferred start time then another
that's just life. personally I like a 9am start time, field is fresh, and ref is into it.

also over a 10 week schedule teams will play each other more then once as well.
as long as the math ups, and match times are spread out as evenly as possible. 99% of
the time I will have even teams, I might even add a week for special
number of teams if I really need too, I have a window of between 9 and 12 players
although 9 has a lot of field to cover, with at least 2 subs per roster.

Sonny

10. could you draw a schedule example on a piece of paper and show it to us

11. I can't follow most of what you just said. I haven't a clue how these sports games are played.

Originally Posted by sonny
also over a 10 week schedule teams will play each other more then once as well.
This re-introduces the exact same problem as before. With 8 teams there is not enough days to cover 2x of every other team, so we have a remainder of 12 games to play when we need 28 and completely excludes these "bye" games.
So we're back to sqrt(1); after every team plays every other team, there remains 12 games left to play. How do we select whom plays for duplicates and factor in these "bye" games? There are not enough games available to play every team twice, so that's not an option unless you bring it up to 56 games in a 10 week period to allot playing every team twice.

You need to figure out the ruleset involved in dealing with remaining days. Standard combinations will not work as there is simply not enough containers to cover the entire set of options.

12. Originally Posted by Fou-Lu
I can't follow most of what you just said. I haven't a clue how these sports games are played.

This re-introduces the exact same problem as before. With 8 teams there is not enough days to cover 2x of every other team, so we have a remainder of 12 games to play when we need 28 and completely excludes these "bye" games.
So we're back to sqrt(1); after every team plays every other team, there remains 12 games left to play. How do we select whom plays for duplicates and factor in these "bye" games? There are not enough games available to play every team twice, so that's not an option unless you bring it up to 56 games in a 10 week period to allot playing every team twice.

You need to figure out the ruleset involved in dealing with remaining days. Standard combinations will not work as there is simply not enough containers to cover the entire set of options.

Fou look at it this way if you have 8 teams you'll have 40 games over 10 weeks,
8 /40 = 5 that's 5 games the same teams will wind up playing each other
during the season that happens all the time,

problem I'm having is coding things so they are spread out evenly based on start times
match ups and byes if needed.

if you have 12 teams you'll then have 60 games total, that's normal and so on

Sonny

13. Originally Posted by poyzn
could you draw a schedule example on a piece of paper and show it to us
This is the ideal data I would need to feed the schedule function

PHP Code:
``` \$teams = array('team1','tean2','team3','team4','team5','team6','team7','team8'); \$Start_Times = array('9am','11am','1pm','3pm', \$NumberWeeks = 10;/ 10 weeks = that's 40 games based on example  ```
the results returned from the function would look like something like this below

WEEK 1
team1 vs team5 (9am)
team2 vs team6 (11am)
team8 vs team3 (1pm)
team7 vs team4 (3pm)

WEEK 2
team3 vs team7 (9am)
team4 vs team8 (11am)
team5 vs team2 (1 pm)
team6 vs team1 (3pm)

WEEK 3
and so on .....

Sonny

14. Guys I'll go even further maybe the function should be given
more data to work with to adopt for different conditions.

1 team names
2 start times
3 number of games to play
4 number of Sundays to play them

I think that's why it may sound confusing
this will let the function calculate things
in a more flexible way because not all seasons will
have the same number of teams.

Sonny

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

#### Posting Permissions

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