mission-gaming/tactician

A modern PHP library for generating structured tournament schedules with deterministic algorithms like Round Robin, Swiss, and Pool play

Installs: 0

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 0

Forks: 0

Open Issues: 1

pkg:composer/mission-gaming/tactician

dev-main 2025-10-02 15:31 UTC

This package is auto-updated.

Last update: 2025-10-03 21:26:35 UTC


README

PHP Version License Build Status codecov

Overview

A modern PHP library for generating structured schedules between participants. Ideal for tournaments (round robin, Swiss, pools) but flexible enough for any scenario where entities need to be paired or grouped into events.

Key Features:

  • ๐Ÿ† Deterministic Algorithms: Round Robin (complete), Swiss and Pool play (coming soon)
  • ๐Ÿ”ง Flexible Constraints: Built-in and custom predicate-based constraint system
  • โœ… Schedule Validation: Comprehensive validation prevents incomplete schedules
  • โšก Memory Efficient: Generator-based iteration for large tournaments
  • ๐ŸŽฏ Modern PHP: PHP 8.2+ with readonly classes and strict typing
  • ๐Ÿงช Test-Driven: Comprehensive test suite with Pest framework
  • ๐Ÿ“ Mathematical Accuracy: Circle method implementation for round-robin
  • ๐Ÿ›ก๏ธ Production Ready: PHPStan level 8 compliance with zero errors

Installation

Install via Composer:

composer require mission-gaming/tactician

Requirements:

  • PHP 8.2+
  • No external dependencies in production

Quick Start

<?php

use MissionGaming\Tactician\DTO\Participant;
use MissionGaming\Tactician\Scheduling\RoundRobinScheduler;
use MissionGaming\Tactician\Constraints\ConstraintSet;
use MissionGaming\Tactician\Constraints\SeedProtectionConstraint;

// Create seeded participants
$participants = [
    new Participant('celtic', 'Celtic', 1),        // Top seed
    new Participant('athletic', 'Athletic Bilbao', 2),  // 2nd seed  
    new Participant('livorno', 'AS Livorno', 3),
    new Participant('redstar', 'Red Star FC', 4),
    new Participant('rayo', 'Rayo Vallecano', 5),
    new Participant('clapton', 'Clapton Community FC', 6),
];

// Configure constraints to protect top seeds from early meetings
$constraints = ConstraintSet::create()
    ->add(new SeedProtectionConstraint(2, 0.5))  // Protect top 2 seeds for 50% of tournament
    ->build();

// Generate schedule
$scheduler = new RoundRobinScheduler($constraints);
$schedule = $scheduler->schedule($participants);

// Iterate through matches
foreach ($schedule as $event) {
    $round = $event->getRound();
    echo ($round ? "Round {$round->getNumber()}" : "No Round") . ": ";
    echo "{$event->getParticipants()[0]->getLabel()} vs {$event->getParticipants()[1]->getLabel()}\n";
}

Key Features

  • ๐Ÿ† Round Robin Tournaments: Complete implementation with circle method algorithm
  • ๐Ÿ”ง Flexible Constraints: Built-in constraints (rest periods, seed protection, role limits) plus custom predicates
  • ๐Ÿ  Multi-Leg Support: Home/away leagues with mirrored, repeated, or shuffled strategies
  • โœ… Schedule Validation: Mathematical validation prevents incomplete tournaments
  • ๐Ÿ›ก๏ธ Production Ready: PHPStan level 8 compliance, comprehensive test coverage
  • โšก Memory Efficient: Iterator-based patterns for large tournaments
  • ๐ŸŽฏ Deterministic: Seeded randomization for reproducible results

Documentation

๐Ÿ“š Complete Usage Guide - Comprehensive examples and patterns
๐Ÿ—๏ธ Architecture - Technical design and core components
๐Ÿ›ฃ๏ธ Roadmap - Detailed development phases and use cases
๐Ÿ“– Contributing Guidelines - Development setup and contribution process
๐Ÿ“š Background - Mission Gaming story and problem space details

Sponsorship

Tag1 Consulting

Initial development of this library was sponsored by Tag1 Consulting, the absolute legends.
Tag1 blog & Tag1TeamTalks Podcast

License

This project is licensed under the MIT License - see the LICENSE file for details.