Tournament runner¶
Orchestrates the three-phase tournament structure:
- Phase 1 -- full round robin within each Smogon tier
- Phase 2 -- adjacent-tier playoffs between tier champions
- Phase 3 -- grand final round robin among all playoff winners
Battle processing is parallelized with ProcessPoolExecutor.
runner ¶
Tournament engine -- runs round robins, playoffs, and the grand final.
Phase 1: Full round robin within each Smogon tier (N*(N-1)/2 matchups). Phase 2: Adjacent tier playoffs (champion of lower tier vs champion of upper). Phase 3: Grand final -- all playoff winners in a full round robin.
All phases use multiprocessing for parallelism.
MatchupRecord
dataclass
¶
TierLeaderboard
dataclass
¶
TierLeaderboard(
tier: str,
gen: int,
entries: list[LeaderboardEntry] = list(),
champion: str | None = None,
champion_win_rate: float = 0.0,
)
Leaderboard for a single tier tournament.
LeaderboardEntry
dataclass
¶
LeaderboardEntry(
rank: int,
name: str,
wins: int,
losses: int,
battles: int,
win_rate: float,
avg_hp_pct: float,
tier: str,
bst: int,
types: str,
)
Single row in a tier leaderboard, ranked by win rate.
PlayoffResult
dataclass
¶
GrandFinalResult
dataclass
¶
GrandFinalResult(
gen: int,
entries: list[GrandFinalEntry] = list(),
champion: str | None = None,
matchup_matrix: dict[str, dict[str, float]] = dict(),
)
Results of the Phase 3 grand final round robin.
GrandFinalEntry
dataclass
¶
Single ranked entry in the grand final leaderboard.
run_tier_tournament ¶
run_tier_tournament(
tier: str,
pokemon: list[Pokemon],
n_battles: int = 20,
rand_ivs: bool = False,
seed: int | None = None,
workers: int = 4,
gen: int = 6,
progress: Any = None,
) -> tuple[TierLeaderboard, list[MatchupRecord]]
Run a full round robin within a tier. Returns (leaderboard, all matchup records). If progress is a tqdm bar, it is advanced by n_battles per completed matchup.
Source code in pokerena/tournament/runner.py
run_tiebreaker ¶
run_tiebreaker(
a: Pokemon,
b: Pokemon,
n_battles: int = 50,
rand_ivs: bool = False,
seed: int | None = None,
gen: int = 6,
) -> str
Run a tiebreaker between two tied Pokemon. Returns the name of the winner.
Source code in pokerena/tournament/runner.py
run_playoff ¶
run_playoff(
lower_tier: str,
upper_tier: str,
lower_champion: Pokemon,
upper_champion: Pokemon,
n_battles: int = 50,
rand_ivs: bool = False,
seed: int | None = None,
gen: int = 6,
) -> PlayoffResult
Run a best-of-N playoff between two tier champions.
Source code in pokerena/tournament/runner.py
run_grand_final ¶
run_grand_final(
gen: int,
finalists: list[tuple[Pokemon, str]],
tier_leaderboards: dict[str, TierLeaderboard],
n_battles: int = 100,
rand_ivs: bool = False,
seed: int | None = None,
workers: int = 4,
progress: Any = None,
) -> GrandFinalResult
Full round robin among playoff winners. Returns a GrandFinalResult with rankings and win-rate matrix. If progress is a tqdm bar, it is advanced by n_battles per completed matchup.
Source code in pokerena/tournament/runner.py
400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 | |
run_full_tournament ¶
run_full_tournament(
gen: int,
pokemon_by_tier: dict[str, list[Pokemon]],
n_battles_phase1: int = 20,
n_battles_phase2: int = 50,
n_battles_phase3: int = 100,
rand_ivs: bool = False,
seed: int | None = None,
workers: int = 4,
progress: Any = None,
) -> dict
Run the full 3-phase tournament for one generation. Returns a results dict with all leaderboards, playoff results, and grand final. If progress is a tqdm bar, it is advanced throughout all three phases.
Source code in pokerena/tournament/runner.py
486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 | |