Card Tourney Setup

Status
Not open for further replies.

keepngoal

OKA: keepingoal
Staff member
Bookie
SuperFanatic
SuperFanatic T2
Jun 20, 2006
39,426
24,745
113
Needing help in administrating a card tourney. Wherein a spreadsheet (or something else) accepts X number of players to play Y number of games, matchups chosen randomly, and each game is never against the same person.

Let's say there are 16 players, and each player needs to play 5 games. And a random game schedule is created from those inputs.

Maybe the math doesn't work with odd number of games played?

anyone have a solution or idea to achieve this? TIA.
 

BCClone

Well Seen Member.
SuperFanatic
SuperFanatic T2
Sep 4, 2011
67,246
63,202
113
Not exactly sure.
Needing help in administrating a card tourney. Wherein a spreadsheet (or something else) accepts X number of players to play Y number of games, matchups chosen randomly, and each game is never against the same person.

Let's say there are 16 players, and each player needs to play 5 games. And a random game schedule is created from those inputs.

Maybe the math doesn't work with odd number of games played?

anyone have a solution or idea to achieve this? TIA.
have a set up with 8 players on each side of a couple tables end to end and then everyone moves to their right or left after each game. Not totally random but if the players don’t know that is what is happening then it turns into random at the beginning.
 

Cyientist

Well-Known Member
SuperFanatic
SuperFanatic T2
Aug 18, 2013
3,762
4,602
113
Ankeny
I copied your post into chatGPT. This was the response.

You’ll need a system that can generate a round-robin style schedule while ensuring that no player faces the same opponent twice. A spreadsheet with some formulas or a script (in Python or Google Sheets) could automate this.
Here’s a rough approach:
  1. Generate a pool of players (16 in this case).
  2. Randomly assign matchupswhile ensuring:
    • Each player plays exactly 5 games.
    • No duplicate matchups occur.
    • Players are distributed evenly across rounds.
  3. Output the schedule in an easy-to-follow format.
Would you prefer a Google Sheets formula-based solution, or a Python script to generate the schedule?

4o

You said:​

Google sheets

ChatGPT said:​

A Google Sheets solution can be set up using formulas and scripts to generate the schedule dynamically. Here's how you can structure it:

Steps to Set Up Your Tournament Schedule in Google Sheets

1. Create the Input Section

  • Column A: List all 16 players.
  • Cell B1: Define the number of games per player (e.g., 5).
  • Column C: A helper column to track match history (optional).

2. Generate Random Matchups

Since each player needs to play exactly 5 games without repeating opponents, you'll need to:
  • Randomly pair players each round.
  • Ensure no duplicate matchups.
  • Balance match frequency.

3. Use Google Sheets Formulas for Randomization

Use RAND() or RANDBETWEEN() to shuffle players and create pairings dynamically.
Example for random sorting:
excel
CopyEdit
=SORT(A2:A17, RANDARRAY(16, 1))
(This shuffles the player list.)
To pair players, use:
excel
CopyEdit
=INDEX($A$2:$A$17, ROW(A1) * 2 - 1) & " vs " & INDEX($A$2:$A$17, ROW(A1) * 2)
(This pairs players 1-2, 3-4, etc.)

4. Avoid Duplicate Matchups

A Google Apps Script (custom function) may be necessary to track previous matchups and regenerate the schedule if duplicates occur.
Would you like a script to automate the process completely, or just formulas to manually refresh matchups when needed?
 

3TrueFans

Just a Happily Married Man
Sep 10, 2009
63,098
61,614
113
Ames
Here is a balanced tournament schedule for 16 participants, where each participant plays in exactly 5 games, and no one faces the same opponent twice.

Tournament Format

  • 16 Participants (P1–P16)
  • Each player plays 5 games
  • Each matchup is unique (no repeated opponents)
  • Round-based format (5 rounds)

Round 1

  • Game 1: P1 vs P2
  • Game 2: P3 vs P4
  • Game 3: P5 vs P6
  • Game 4: P7 vs P8
  • Game 5: P9 vs P10
  • Game 6: P11 vs P12
  • Game 7: P13 vs P14
  • Game 8: P15 vs P16

Round 2

  • Game 9: P1 vs P3
  • Game 10: P2 vs P4
  • Game 11: P5 vs P7
  • Game 12: P6 vs P8
  • Game 13: P9 vs P11
  • Game 14: P10 vs P12
  • Game 15: P13 vs P15
  • Game 16: P14 vs P16

Round 3

  • Game 17: P1 vs P5
  • Game 18: P2 vs P6
  • Game 19: P3 vs P7
  • Game 20: P4 vs P8
  • Game 21: P9 vs P13
  • Game 22: P10 vs P14
  • Game 23: P11 vs P15
  • Game 24: P12 vs P16

Round 4

  • Game 25: P1 vs P9
  • Game 26: P2 vs P10
  • Game 27: P3 vs P11
  • Game 28: P4 vs P12
  • Game 29: P5 vs P13
  • Game 30: P6 vs P14
  • Game 31: P7 vs P15
  • Game 32: P8 vs P16

Round 5

  • Game 33: P1 vs P13
  • Game 34: P2 vs P14
  • Game 35: P3 vs P15
  • Game 36: P4 vs P16
  • Game 37: P5 vs P9
  • Game 38: P6 vs P10
  • Game 39: P7 vs P11
  • Game 40: P8 vs P12

Schedule Summary

  • Each participant plays 5 unique opponents.
  • No one plays the same opponent twice.
  • The schedule is balanced to ensure fairness.
Would you like any modifications, such as adjusting for time slots or adding rest periods?
 
  • Like
Reactions: keepngoal

keepngoal

OKA: keepingoal
Staff member
Bookie
SuperFanatic
SuperFanatic T2
Jun 20, 2006
39,426
24,745
113
I copied your post into chatGPT. This was the response.

You’ll need a system that can generate a round-robin style schedule while ensuring that no player faces the same opponent twice. A spreadsheet with some formulas or a script (in Python or Google Sheets) could automate this.
Here’s a rough approach:
  1. Generate a pool of players (16 in this case).
  2. Randomly assign matchupswhile ensuring:
    • Each player plays exactly 5 games.
    • No duplicate matchups occur.
    • Players are distributed evenly across rounds.
  3. Output the schedule in an easy-to-follow format.
Would you prefer a Google Sheets formula-based solution, or a Python script to generate the schedule?

4o

You said:​

Google sheets

ChatGPT said:​

A Google Sheets solution can be set up using formulas and scripts to generate the schedule dynamically. Here's how you can structure it:

Steps to Set Up Your Tournament Schedule in Google Sheets

1. Create the Input Section

  • Column A: List all 16 players.
  • Cell B1: Define the number of games per player (e.g., 5).
  • Column C: A helper column to track match history (optional).

2. Generate Random Matchups

Since each player needs to play exactly 5 games without repeating opponents, you'll need to:
  • Randomly pair players each round.
  • Ensure no duplicate matchups.
  • Balance match frequency.

3. Use Google Sheets Formulas for Randomization

Use RAND() or RANDBETWEEN() to shuffle players and create pairings dynamically.
Example for random sorting:
excel
CopyEdit
=SORT(A2:A17, RANDARRAY(16, 1))
(This shuffles the player list.)
To pair players, use:
excel
CopyEdit
=INDEX($A$2:$A$17, ROW(A1) * 2 - 1) & " vs " & INDEX($A$2:$A$17, ROW(A1) * 2)
(This pairs players 1-2, 3-4, etc.)

4. Avoid Duplicate Matchups

A Google Apps Script (custom function) may be necessary to track previous matchups and regenerate the schedule if duplicates occur.
Would you like a script to automate the process completely, or just formulas to manually refresh matchups when needed?
Thank you. A script to automate is preferred. But a manual push is cool too. Not sure where the sort and index go.
 

keepngoal

OKA: keepingoal
Staff member
Bookie
SuperFanatic
SuperFanatic T2
Jun 20, 2006
39,426
24,745
113
Here is a balanced tournament schedule for 16 participants, where each participant plays in exactly 5 games, and no one faces the same opponent twice.

Tournament Format

  • 16 Participants (P1–P16)
  • Each player plays 5 games
  • Each matchup is unique (no repeated opponents)
  • Round-based format (5 rounds)

Round 1

  • Game 1: P1 vs P2
  • Game 2: P3 vs P4
  • Game 3: P5 vs P6
  • Game 4: P7 vs P8
  • Game 5: P9 vs P10
  • Game 6: P11 vs P12
  • Game 7: P13 vs P14
  • Game 8: P15 vs P16

Round 2

  • Game 9: P1 vs P3
  • Game 10: P2 vs P4
  • Game 11: P5 vs P7
  • Game 12: P6 vs P8
  • Game 13: P9 vs P11
  • Game 14: P10 vs P12
  • Game 15: P13 vs P15
  • Game 16: P14 vs P16

Round 3

  • Game 17: P1 vs P5
  • Game 18: P2 vs P6
  • Game 19: P3 vs P7
  • Game 20: P4 vs P8
  • Game 21: P9 vs P13
  • Game 22: P10 vs P14
  • Game 23: P11 vs P15
  • Game 24: P12 vs P16

Round 4

  • Game 25: P1 vs P9
  • Game 26: P2 vs P10
  • Game 27: P3 vs P11
  • Game 28: P4 vs P12
  • Game 29: P5 vs P13
  • Game 30: P6 vs P14
  • Game 31: P7 vs P15
  • Game 32: P8 vs P16

Round 5

  • Game 33: P1 vs P13
  • Game 34: P2 vs P14
  • Game 35: P3 vs P15
  • Game 36: P4 vs P16
  • Game 37: P5 vs P9
  • Game 38: P6 vs P10
  • Game 39: P7 vs P11
  • Game 40: P8 vs P12

Schedule Summary

  • Each participant plays 5 unique opponents.
  • No one plays the same opponent twice.
  • The schedule is balanced to ensure fairness.
Would you like any modifications, such as adjusting for time slots or adding rest periods?
Thank you. The 16 and 5 was an example but the inputs could change (certainly the number of players). And hoping for something automatic via script or manual resfresh.
 

Cyientist

Well-Known Member
SuperFanatic
SuperFanatic T2
Aug 18, 2013
3,762
4,602
113
Ankeny
Thank you. A script to automate is preferred. But a manual push is cool too. Not sure where the sort and index go.

Steps to Implement the Script

  1. Open Google Sheets and list the 16 players in column A.
  2. Click Extensions → Apps Script.
  3. Delete any existing code and paste the script below.
  4. Click the disk icon (Save), then click Run.
  5. The schedule will be generated in the sheet.

Google Apps Script for Generating the Schedule

This script:

  • Randomly selects matchups.
  • Ensures each player plays exactly 5 games.
  • Avoids duplicate opponents.
javascript
CopyEdit
function generateTournamentSchedule() {
var sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
var players = sheet.getRange("A2:A17").getValues().flat().filter(String); // Read players from column A
var totalGames = 5; // Each player plays 5 games
var schedule = [];
var matchups = new Map();

if (players.length !== 16) {
SpreadsheetApp.getUi().alert("Error: Please enter exactly 16 players in column A.");
return;
}

// Initialize match tracking for each player
players.forEach(player => matchups.set(player, new Set()));

var attempts = 0;
while (schedule.length < (16 * totalGames) / 2) {
var shuffledPlayers = players.sort(() => 0.5 - Math.random()); // Shuffle players

var roundMatches = [];
var usedPlayers = new Set();

for (var i = 0; i < shuffledPlayers.length - 1; i++) {
var player1 = shuffledPlayers;

if (usedPlayers.has(player1) || matchups.get(player1).size >= totalGames) continue;

for (var j = i + 1; j < shuffledPlayers.length; j++) {

var player2 = shuffledPlayers[j];

if (
!usedPlayers.has(player2) &&
matchups.get(player1).size < totalGames &&
matchups.get(player2).size < totalGames &&
!matchups.get(player1).has(player2)
) {
// Create a match
roundMatches.push([player1, player2]);

// Track matches
matchups.get(player1).add(player2);
matchups.get(player2).add(player1);
usedPlayers.add(player1);
usedPlayers.add(player2);

break;
}
}
}

// If we couldn't generate enough matches after multiple attempts, reset and try again
if (roundMatches.length === 0 && attempts < 1000) {
matchups.forEach((set, key) => matchups.set(key, new Set())); // Reset matchups
schedule = [];
attempts++;

continue;
}

schedule.push(...roundMatches);
}

// Output the schedule to the sheet
sheet.getRange("C1:D1").setValues([["Player 1", "Player 2"]]); // Headers
sheet.getRange(2, 3, schedule.length, 2).setValues(schedule);
}




How It Works

  1. Reads player names from column A (A2:A17).
  2. Randomly assigns matchups while ensuring:
    • Each player plays exactly 5 games.
    • No repeated matchups.
  3. Outputs the schedule in columns C and D.

How to Run the Script

  1. Enter 16 player names in column A.
  2. Go to Extensions → Apps Script.
  3. Paste the script and click Run.
  4. The schedule will be generated in columns C & D.
 
  • Friendly
Reactions: keepngoal

Cyientist

Well-Known Member
SuperFanatic
SuperFanatic T2
Aug 18, 2013
3,762
4,602
113
Ankeny
That smiley face should actually be "C1: D1" but with no spaces. CF really wants the smiley face.
 
  • Haha
Reactions: keepngoal

keepngoal

OKA: keepingoal
Staff member
Bookie
SuperFanatic
SuperFanatic T2
Jun 20, 2006
39,426
24,745
113
Thanks everyone. It appears AI is the easiest way to make this happen dynamically. CF is amazing.
 
Status
Not open for further replies.

Latest posts

Help Support Us

Become a patron