src.interface
IGameResult
dataclass
IGameResult(winners: frozenset[UUID], scores: tuple[tuple[UUID, int], ...] | None = None)
One game of a match: the players who did not lose it.
One UID means that player won the game. Two or more mean the game was
drawn among them. Every other player seated in the pod lost the game.
scores optionally records each player's score for the game; Commander
and 1v1 MTG never set it.
IHashable
IHashable(uid: UUID | None = None)
Interface for hashable objects with UUIDs.
Initializes the IHashable object.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
uid
|
UUID | None
|
The UUID of the object. If None, a new UUID is generated. |
None
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If the UUID has a collision or is of invalid type. |
Source code in src/interface.py
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 | |
get
classmethod
get(ID: UUID) -> IHashable
Retrieves an object by its UUID.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ID
|
UUID
|
The UUID of the object. |
required |
Returns:
| Type | Description |
|---|---|
IHashable
|
The object with the specified UUID. |
Source code in src/interface.py
90 91 92 93 94 95 96 97 98 99 100 | |
IPairingLogic
Bases: ABC
Interface for pairing logic.
advance_topcut
advance_topcut(tour_round: IRound, standings: list[IPlayer]) -> None
Called once per playoff round before make_pairings.
The base implementation is a no-op, correct for ordinary Swiss pairing. Top-cut pairing logics override this to give seeded byes.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
tour_round
|
IRound
|
The current round. |
required |
standings
|
list[IPlayer]
|
The list of players sorted by standing. |
required |
Source code in src/interface.py
338 339 340 341 342 343 344 345 346 347 348 | |
make_pairings
abstractmethod
make_pairings(tour_round: IRound, players: set[IPlayer], pods: Sequence[IPod]) -> set[IPlayer]
Creates pairings for a round.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
tour_round
|
IRound
|
The current round. |
required |
players
|
set[IPlayer]
|
The set of players to pair. |
required |
pods
|
Sequence[IPod]
|
The list of available pods. |
required |
Returns:
| Type | Description |
|---|---|
set[IPlayer]
|
A set of players who could not be paired (if any). |
Source code in src/interface.py
322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 | |
supports_pod_sizes
classmethod
supports_pod_sizes(pod_sizes: Sequence[int]) -> bool
Whether this algorithm can pair a tournament with these pod sizes.
True if it supports any size (SUPPORTED_POD_SIZES is None) or every given size is in its supported set (an empty list supports nothing).
Source code in src/interface.py
297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 | |
IPlayer
IPlayer(uid: UUID | None = None)
Bases: IHashable, ABC
Interface for a player.
Source code in src/interface.py
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 | |
ELocation
Bases: IntEnum
Enum for player location.
EResult
Bases: IntEnum
Enum for match result.
IPod
IPod(uid: UUID | None = None)
Bases: IHashable, ABC
Interface for a pod.
Source code in src/interface.py
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 | |
EResult
Bases: IntEnum
Enum for pod result.
IRound
IRound(uid: UUID | None = None)
Bases: IHashable, ABC
Interface for a round.
Source code in src/interface.py
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 | |
rng
abstractmethod
rng(*purpose: object) -> random.Random
The generator for one random decision in this round, keyed on the
round's seed, seq, stage, pairing inputs and purpose.
Source code in src/interface.py
271 272 273 274 | |
IRuleset
IRuleset(name: str)
Bases: ABC
Interface for a game's rules: match reports and playoffs.
Same plugin shape as IScoringLogic/IPairingLogic (IS_COMPLETE, name, PARAM_SPEC/DEFAULT_PARAMS loaded from the sidecar in init_subclass). See docs/tournament-log-spec.md, "Rulesets", for the full contract.
Source code in src/interface.py
508 509 | |
match_winners
abstractmethod
match_winners(pod: IPod) -> frozenset[UUID]
Players who did not lose the match: one = winner, several = drew.
Called only when pod.games is non-empty. Must be total: it runs on stored data (old files, rosters edited after reporting) and must never raise.
Source code in src/interface.py
536 537 538 539 540 541 542 543 544 | |
params
params(tour_round: IRound) -> dict[str, Any]
This round's ruleset params: overrides on top of the class defaults. Cold path only (call once, not per player/pod).
Source code in src/interface.py
517 518 519 520 521 | |
playoff_standings
playoff_standings(tour: ITournament, tour_round: IRound) -> list[IPlayer] | None
Opt-in hook: the full standings after a playoff round.
Tournament.get_standings asks this first for a non-Swiss tour_round. None (the default) means "not handled": core runs its built-in playoff ordering unchanged.
Source code in src/interface.py
570 571 572 573 574 575 576 577 578 579 | |
random_report
abstractmethod
random_report(pod: IPod) -> list[IGameResult]
A plausible valid report for Tournament.random_results.
Uses the random module so tests can seed it.
Source code in src/interface.py
556 557 558 559 560 561 562 | |
report_from_winners
abstractmethod
report_from_winners(pod: IPod, winners: Iterable[UUID]) -> list[IGameResult]
Turns "A won" / "A and B drew" into a canonical report.
Backs the report_win/report_draw shorthand.
Source code in src/interface.py
546 547 548 549 550 551 552 553 554 | |
swiss_eliminations
swiss_eliminations(tour_round: IRound, standings: Sequence[IPlayer]) -> set[IPlayer]
Opt-in hook: players out of the tournament before this Swiss round.
Round.create_pairings calls it for each Swiss round after the first, before the pods are built, with the previous round's standings. Returned players are disabled like a top-cut cut (same disable_player), so they sit out but stay ranked. The default eliminates no one.
When a ruleset overrides this hook, each pairing of the round first resets its disabled players to the previous round's, so re-pairing after reset_pods drops stale eliminations. As with top cut, a player disabled by hand in this round must be disabled again after a re-pair.
Source code in src/interface.py
581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 | |
swiss_pairing_logic
abstractmethod
swiss_pairing_logic(tour: ITournament, seq: int) -> str
Default pairing logic for Swiss round seq when config.pairing_rounds sets none.
Source code in src/interface.py
564 565 566 567 568 | |
validate_report
abstractmethod
validate_report(pod: IPod, games: Sequence[IGameResult]) -> None
Raises ValueError if games is not a valid complete report for pod in its round. Never mutates. The message should be fit for a tournament organiser to read.
Source code in src/interface.py
529 530 531 532 533 534 | |
IScoringLogic
Bases: ABC
Interface for points, standings tiebreakers, and their export columns.
compute_ratings
abstractmethod
compute_ratings(tour: ITournament, tour_round: IRound) -> Mapping[UUID, float]
Computes every player's point total as of a given round.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
tour
|
ITournament
|
The tournament. |
required |
tour_round
|
IRound
|
The round up to which to compute points. |
required |
Returns:
| Type | Description |
|---|---|
Mapping[UUID, float]
|
A mapping of player UID to point total. |
Source code in src/interface.py
392 393 394 395 396 397 398 399 400 401 402 403 404 405 | |
pointrate_denominator
abstractmethod
pointrate_denominator(tour_round: IRound) -> float
The value a player's rating is divided by to get a 0-1 pointrate.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
tour_round
|
IRound
|
The round the pointrate is being computed for. |
required |
Returns:
| Type | Description |
|---|---|
float
|
The denominator to divide a rating by. |
Source code in src/interface.py
445 446 447 448 449 450 451 452 453 454 455 | |
rating
abstractmethod
rating(player: IPlayer, tour_round: IRound) -> float
Computes one player's point total as of a given round.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
player
|
IPlayer
|
The player to compute the rating for. |
required |
tour_round
|
IRound
|
The round up to which to compute points. |
required |
Returns:
| Type | Description |
|---|---|
float
|
The player's point total. |
Source code in src/interface.py
407 408 409 410 411 412 413 414 415 416 417 418 | |
standings_columns
standings_columns(tour: ITournament, tour_round: IRound) -> list[tuple[str, Mapping[UUID, str]]]
Extra standings-export columns: (header, formatted cells by UID).
Source code in src/interface.py
439 440 441 442 443 | |
standings_keys
standings_keys(tour: ITournament, tour_round: IRound, ratings: Mapping[Any, float]) -> Mapping[UUID, tuple]
Swiss sort keys, descending: points, then scoring tiebreakers.
The default has no tiebreakers. UID order keeps exact ties stable without assigning competitive significance to that order.
Source code in src/interface.py
420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 | |
supports_pod_sizes
classmethod
supports_pod_sizes(pod_sizes: Sequence[int]) -> bool
Whether this algorithm can score a tournament with these pod sizes.
True if it supports any size (SUPPORTED_POD_SIZES is None) or every given size is in its supported set (an empty list supports nothing).
Source code in src/interface.py
371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 | |
IStandingsExport
Bases: ABC
Interface for standings export configuration.
ITournamentConfiguration
Bases: ABC
ruleset_overrides
abstractmethod
ruleset_overrides(tour_round: IRound) -> Mapping[str, Any]
This round's ruleset param overrides (see IRuleset.params()).
A Swiss round reads pairing_rounds[seq]["ruleset_params"]; a playoff round reads playoff_rounds[stage.value]["ruleset_params"].
Source code in src/interface.py
647 648 649 650 651 652 653 654 | |
SortMethod
Bases: IntEnum
Enum for sorting methods.
SortOrder
Bases: IntEnum
Enum for sorting order.