定制 mnito/round-robin 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

mnito/round-robin

Composer 安装命令:

composer require mnito/round-robin

包简介

Round-robin schedule generation implementation in PHP

README 文档

README

Build Status

Round-robin schedule generation reference implementation for PHP 7 licensed under the MIT license

Features

  • Efficient schedule generation enabled by an efficient round-robin rotation function
  • Ability to generate an arbitrary number of rounds
  • Support for any number of teams by adding a bye for odd-numbered team counts
  • Simple, concise implementation for easy analysis of the algorithm
  • Unit tested
  • Documented
  • Modern PHP 7 code
  • Object-oriented and procedural APIs

Basic Usage

Generating Common Schedules

Generate a random schedule where each player meets every other player once:

$teams = ['The 1st', '2 Good', 'We 3', '4ward'];
$scheduleBuilder = new ScheduleBuilder($teams);
$schedule = $scheduleBuilder->build();

or

$teams = ['The 1st', '2 Good', 'We 3', '4ward'];
$schedule = schedule($teams);

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:

$teams = ['The 1st', '2 Good', 'We 3', '4ward'];
$rounds = (($count = count($teams)) % 2 === 0 ? $count - 1 : $count) * 2;
$scheduleBuilder = new ScheduleBuilder($teams, $rounds);
$schedule = $scheduleBuilder->build();

or

$teams = ['The 1st', '2 Good', 'We 3', '4ward'];
$rounds = (($count = count($teams)) % 2 === 0 ? $count - 1 : $count) * 2;
$schedule = schedule($teams, $rounds);

Generate a schedule without randomly shuffling the teams using the $shuffle boolean parameter:

$teams = ['The 1st', '2 Good', 'We 3', '4ward'];
$scheduleBuilder = new ScheduleBuilder($teams);
$scheduleBuilder->doNotShuffle();
$schedule = $scheduleBuilder->build();

or

$teams = ['The 1st', '2 Good', 'We 3', '4ward'];
$schedule = schedule($teams, null, false);

Use your own seed with the $seed integer parameter for predetermined shuffling:

$teams = ['The 1st', '2 Good', 'We 3', '4ward'];
$scheduleBuilder = new ScheduleBuilder($teams);
$scheduleBuilder->shuffle(89);
$schedule = $scheduleBuilder->build();

or

$teams = ['The 1st', '2 Good', 'We 3', '4ward'];
$schedule = schedule($teams, null, true, 89);

Looping Through A Schedule

Looping Through the Full Schedule

Setup:

$teams = ['The 1st', '2 Good', 'We 3', '4ward'];
$schedule = schedule($teams, null, true, 89);

or

$scheduleBuilder = new ScheduleBuilder();
$scheduleBuilder->setTeams($teams);
$scheduleBuilder->setRounds(10);
$scheduleBuilder->doNotShuffle();
$schedule = $scheduleBuilder->build();

Loop through:

<?php foreach($schedule as $round => $matchups){ ?>
    <h3>Round <?=$round?></h3>
    <ul>
    <?php foreach($matchups as $matchup) { ?>
        <li><?=$matchup[0] ?? '*BYE*'?> vs. <?=$matchup[1] ?? '*BYE*'?></li>
    <?php } ?>
    </ul>
<?php } ?>

Looping Through Team Schedules

<?php

$scheduleBuilder = new ScheduleBuilder($teams, 10);
$scheduleBuilder->shuffle(18);
$schedule = $scheduleBuilder->build();
?>


<?php foreach($teams as $team) { ?>
    <h3><?=$team?></h3>
    <ol>
    <?php foreach($schedule($team) as $contest) { ?>
        <li><?=(($contest['home'] ? '' : '@').($contest['team'] ?? '*BYE*'))?></li>
    <?php } ?>
    </ol>
<?php } ?>

License

MIT License

Author

Michael P. Nitowski <mike@nitow.ski>

统计信息

  • 总下载量: 71.6k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 62
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 61
  • Watchers: 6
  • Forks: 15
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2016-09-08

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固