I am trying to create a sports league scheduler.  I am having trouble identifying an algorithm to help me efficiently fill in each slot.Sample data to build the schedule would be:10 teamsEach team plays each other 1 time (45 total gamesrequired)Each team plays no more than 1 time per dayIn my testing I am using 9 days with 5 slots per day.Combo Table (contains 45 combos)IDTeam1IDTeam2IDbitAssignedSchedule Table (contains 45 time slots)scheduleIDhomeTeamIDawayTeamIDGameDateGameTimeRight now my existing procedures fill about 90% of the slots leaving 10% of my slots empty to a scheduling conflict based off the rules above.I loop over my schedule table in ascending date/time order.My first slot could be Saturday at 8am.I query a list of teams that haven't been scheduled yet.  I then make an array of possible combinations of those teams.  I then use that array to pull 1 random record from my combinations table from of combinations that haven't been scheduled yet and I place those teams on the schedule.  I then set that combination as used.I repeat the loop over and over again and each time my list of available teams gets smaller and my array as a result is smaller too.I'm finding that some days go fine, and on other days my final last 2 remaining teams have already played in a previous week so they are not added to the schedule again.The only thing I havent tried yet is to reset the conflict days and try them over again to see if I get better placements.Does anyone have any suggestions?
Need help identifying a league scheduling algorithm
algorithms;scheduling