Skip to main content

Easily represent, progress, and visualize Bracket-style Tournaments

Project description

Tourneyket

Package to let you easily represent and progress Bracket-style single elimination Tournaments, allowing you to focus on matchup logic and analysis without worrying about the boilerplate. Supports 2, 4, 8, 16, 32, 64...n^2 starting teams.

The Bracket object accepts an initial bracket and a function to select matchup winner. Automatically fills out the rest of the bracket using whatever logic you provide, and implements a method to print out the final bracket to console in a nice, bracket shaped format.

Example:

from tourneyket import Bracket

# List of competitors. 1 plays 2, 3 plays 4... and so on. Likewise, winner of 1v2 plays winner of 3v4, etc.
my_tournament = [{"name": "Kitten State", "power_level": 9001},
                {"name": "Bunnyville", "power_level": 6000},
                {"name": "Muscle Hamsters", "power_level": 2},
                {"name": "Doggy Dog World", "power_level": 8500},
                {"name": "Horsies", "power_level": 8934},
                {"name": "Lizard Wizards", "power_level": 7800},
                {"name": "Ole Penguin", "power_level": 8300},
                {"name": "Pigchamps", "power_level": 7500}]

def pick_by_power_level(a, b):
    if a["power_level"] > b["power_level"]:
        return a 
    else: 
        return b

MyBracket = Bracket(my_tournament)
# play_out_bracket accepts an optional pick_winner parameter. 
# Default just picks a random winner in each matchup.
MyBracket.play_out_bracket(pick_winner=pick_by_power_level)
# Optional formatting= parameter lets you specify what to print instead of just printing the whole dictionary
# Can also specify spacing for how it is printed. Default is 20.
MyBracket.print_bracket(formatting=lambda t: t["name"], spaces=20)

Which outputs:


Kitten State
 |----------------- Kitten State
Bunnyville
                     |----------------- Kitten State
Muscle Hamsters
 |----------------- Doggy Dog World
Doggy Dog World
                                         |----------------- Kitten State
Horsies
 |----------------- Horsies
Lizard Wizards
                     |----------------- Horsies
Ole Penguin
 |----------------- Ole Penguin
Pigchamps

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

tourneyket-0.1.6.tar.gz (5.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

tourneyket-0.1.6-py3-none-any.whl (5.1 kB view details)

Uploaded Python 3

File details

Details for the file tourneyket-0.1.6.tar.gz.

File metadata

  • Download URL: tourneyket-0.1.6.tar.gz
  • Upload date:
  • Size: 5.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.13.2

File hashes

Hashes for tourneyket-0.1.6.tar.gz
Algorithm Hash digest
SHA256 c9441b6e79aa72030948106b21ccd9da945ac479a8299b669ba36f685543a018
MD5 0fb36c9366c4f9fce71155757f29c13e
BLAKE2b-256 c08cca3be8298b22ee6e75838a5cf495b9cc142204414ab5ddfefc67dc0b5157

See more details on using hashes here.

File details

Details for the file tourneyket-0.1.6-py3-none-any.whl.

File metadata

  • Download URL: tourneyket-0.1.6-py3-none-any.whl
  • Upload date:
  • Size: 5.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.13.2

File hashes

Hashes for tourneyket-0.1.6-py3-none-any.whl
Algorithm Hash digest
SHA256 bbf56466cfd43a9c8883bcdb51778135f112f63d71beb6b34e433157b843e315
MD5 7ae4fc09ccb5630aa630c6632af1baec
BLAKE2b-256 9e47e3b15c299675bb7c0e91c782e0efdbeaa421228286b453e5ebfa810efc11

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page