{"id":15296268,"url":"https://github.com/mnito/round-robin","last_synced_at":"2025-08-21T10:31:00.794Z","repository":{"id":57018526,"uuid":"67635281","full_name":"mnito/round-robin","owner":"mnito","description":"Round-robin schedule generation library for PHP","archived":false,"fork":false,"pushed_at":"2021-09-12T14:24:59.000Z","size":58,"stargazers_count":61,"open_issues_count":5,"forks_count":14,"subscribers_count":7,"default_branch":"main","last_synced_at":"2024-12-10T08:50:52.525Z","etag":null,"topics":["generator","home-away","php7","round-robin","schedule","scheduler","tournament"],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mnito.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-09-07T19:02:33.000Z","updated_at":"2024-09-08T13:08:24.000Z","dependencies_parsed_at":"2022-08-22T20:30:53.460Z","dependency_job_id":null,"html_url":"https://github.com/mnito/round-robin","commit_stats":null,"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mnito%2Fround-robin","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mnito%2Fround-robin/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mnito%2Fround-robin/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mnito%2Fround-robin/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mnito","download_url":"https://codeload.github.com/mnito/round-robin/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":230507051,"owners_count":18236944,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["generator","home-away","php7","round-robin","schedule","scheduler","tournament"],"created_at":"2024-09-30T18:09:55.489Z","updated_at":"2024-12-19T22:07:56.567Z","avatar_url":"https://github.com/mnito.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# round-robin\n[![Build Status](https://app.travis-ci.com/mnito/round-robin.svg)](https://app.travis-ci.com/mnito/round-robin)\n\nRound-robin schedule generation reference implementation for PHP 7 licensed under the MIT license\n\n## Features\n\n- Efficient schedule generation enabled by an efficient round-robin rotation function\n- Ability to generate an arbitrary number of rounds\n- Support for any number of teams by adding a bye for odd-numbered team counts\n- Simple, concise implementation for easy analysis of the algorithm\n- Unit tested\n- Documented\n- Modern PHP 7 code\n- Object-oriented and procedural APIs\n\n## Basic Usage\n\n### Generating Common Schedules\n\n#### Generate a random schedule where each player meets every other player once:\n\n```php\n$teams = ['The 1st', '2 Good', 'We 3', '4ward'];\n$scheduleBuilder = new ScheduleBuilder($teams);\n$schedule = $scheduleBuilder-\u003ebuild();\n```\n\nor\n\n```php\n$teams = ['The 1st', '2 Good', 'We 3', '4ward'];\n$schedule = schedule($teams);\n```\n\n\n#### Generate a random home-away schedule where each player meets every other player twice, once at home and once away, using the $rounds integer parameter:\n\n```php\n$teams = ['The 1st', '2 Good', 'We 3', '4ward'];\n$rounds = (($count = count($teams)) % 2 === 0 ? $count - 1 : $count) * 2;\n$scheduleBuilder = new ScheduleBuilder($teams, $rounds);\n$schedule = $scheduleBuilder-\u003ebuild();\n```\n\nor\n\n```php\n$teams = ['The 1st', '2 Good', 'We 3', '4ward'];\n$rounds = (($count = count($teams)) % 2 === 0 ? $count - 1 : $count) * 2;\n$schedule = schedule($teams, $rounds);\n```\n\n#### Generate a schedule without randomly shuffling the teams using the $shuffle boolean parameter:\n\n```php\n$teams = ['The 1st', '2 Good', 'We 3', '4ward'];\n$scheduleBuilder = new ScheduleBuilder($teams);\n$scheduleBuilder-\u003edoNotShuffle();\n$schedule = $scheduleBuilder-\u003ebuild();\n```\n\nor\n\n```php\n$teams = ['The 1st', '2 Good', 'We 3', '4ward'];\n$schedule = schedule($teams, null, false);\n```\n\n#### Use your own seed with the $seed integer parameter for predetermined shuffling:\n```php\n$teams = ['The 1st', '2 Good', 'We 3', '4ward'];\n$scheduleBuilder = new ScheduleBuilder($teams);\n$scheduleBuilder-\u003eshuffle(89);\n$schedule = $scheduleBuilder-\u003ebuild();\n```\nor\n\n```php\n$teams = ['The 1st', '2 Good', 'We 3', '4ward'];\n$schedule = schedule($teams, null, true, 89);\n```\n\n### Looping Through A Schedule\n\n#### Looping Through the Full Schedule\n\nSetup:\n\n```php\n$teams = ['The 1st', '2 Good', 'We 3', '4ward'];\n$schedule = schedule($teams, null, true, 89);\n```\n\nor\n\n```php\n$scheduleBuilder = new ScheduleBuilder();\n$scheduleBuilder-\u003esetTeams($teams);\n$scheduleBuilder-\u003esetRounds(10);\n$scheduleBuilder-\u003edoNotShuffle();\n$schedule = $scheduleBuilder-\u003ebuild();\n```\n\nLoop through:\n\n```php\n\u003c?php foreach($schedule as $round =\u003e $matchups){ ?\u003e\n    \u003ch3\u003eRound \u003c?=$round?\u003e\u003c/h3\u003e\n    \u003cul\u003e\n    \u003c?php foreach($matchups as $matchup) { ?\u003e\n        \u003cli\u003e\u003c?=$matchup[0] ?? '*BYE*'?\u003e vs. \u003c?=$matchup[1] ?? '*BYE*'?\u003e\u003c/li\u003e\n    \u003c?php } ?\u003e\n    \u003c/ul\u003e\n\u003c?php } ?\u003e\n```\n\n#### Looping Through Team Schedules\n```php\n\u003c?php\n\n$scheduleBuilder = new ScheduleBuilder($teams, 10);\n$scheduleBuilder-\u003eshuffle(18);\n$schedule = $scheduleBuilder-\u003ebuild();\n?\u003e\n\n\n\u003c?php foreach($teams as $team) { ?\u003e\n    \u003ch3\u003e\u003c?=$team?\u003e\u003c/h3\u003e\n    \u003col\u003e\n    \u003c?php foreach($schedule($team) as $contest) { ?\u003e\n        \u003cli\u003e\u003c?=(($contest['home'] ? '' : '@').($contest['team'] ?? '*BYE*'))?\u003e\u003c/li\u003e\n    \u003c?php } ?\u003e\n    \u003c/ol\u003e\n\u003c?php } ?\u003e\n```\n\n## License\n\nMIT License\n\n## Author\n\nMichael P. Nitowski \u003c[mike@nitow.ski](mailto:mike@nitow.ski)\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmnito%2Fround-robin","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmnito%2Fround-robin","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmnito%2Fround-robin/lists"}