An open API service indexing awesome lists of open source software.

https://github.com/fezcode/go-tournament-brackets

A Go library (and an executable) for creating and running tournaments.
https://github.com/fezcode/go-tournament-brackets

Last synced: 3 months ago
JSON representation

A Go library (and an executable) for creating and running tournaments.

Awesome Lists containing this project

README

          

# Go Tournament Bracket Generator Lib

A simple and flexible Go library for creating and managing single-elimination tournament brackets.
This project also includes a fully interactive command-line application to run a tournament from start to finish.

## What Is It?
This project provides two main components:

* A Go Library: A set of data models and functions that you can import into your own Go applications to handle tournament logic programmatically.
It correctly calculates rounds, match-ups, and byes for any number of participants.

* An Interactive CLI: A runnable application (main.go) that uses the library to provide a step-by-step command-line interface.
* You can enter participant names, and the app will generate a bracket and then prompt you for the winner of each match until a champion is crowned.

## Features

* Single-Elimination Brackets: Generates a standard single-elimination tournament structure.
* Automatic Bye Handling: Automatically calculates and assigns byes for a number of participants that is not a power of two.
* Interactive CLI: Comes with a ready-to-run terminal application to manage a tournament in real-time.
* ASCII Bracket Display: Prints the current state of the tournament bracket to the console, so you can easily track matchups and winners.
* Simple and Extensible: Built with clear and straightforward data models, making it easy to extend with new features.

## Usage
### As a Library

To use this package in your own Go project, you can install it with `go get`:

`go get github.com/fezcode/go-tournament-brackets`

Then, you can import and use it in your code:

```go
package main

import (
"fmt"
"github.com/fezcode/go-tournament-brackets"
)

func main() {
participants := []string{"Team Alpha", "Team Bravo", "Team Charlie", "Team Delta", "Team Echo"}

// Create a new tournament
tourney, err := tournament.NewTournament("My Cup", tournament.SingleElimination, participants, nil)
if err != nil {
panic(err)
}

// Print the initial bracket state
tourney.PrintAscii()

// From here, you can programmatically set winners and advance them
// For example, to set Team Alpha (ID: 1) as the winner of their first match:
// tourney.SetWinner(roundIndex, matchIndex, 1)
}

```