Card Tournament Optimizer Guide

The seed decides who plays with and against whom in every round. It says nothing about which table each foursome sits at, or in what order the rounds are played. This page explains how the optimizer chooses both so that every player gets around the room evenly, using two search stages one after the other.

The short version

1The seed fixes the foursomes. The optimizer only chooses the round order and the table number of each foursome.
2Stage 1 A beam search builds clean schedules round by round, never letting anyone sit at the same table twice in a row.
3Stage 2 Annealing reshuffles the whole schedule at once, hunting for something closer to the ideal. It only replaces Stage 1's answer if it scores better.

One run, start to finish

Seed rounds who plays with whom (fixed) Stage 1 · Beam search label rounds one at a time keep the best partial schedules try other round orders repeat from the best order Rule 3 never broken Stage 2 · Annealing random small changes accept some bad ones early cool down, then clear repeats several runs, keep the best only clean results count Keep the better one by score
Stage 1 runs for the attempts you allow (or until it stops improving), with its time limit stretched to fit at least 6 attempts on big seeds. Stage 2 then gets about half that time, at least 6 seconds and enough for 3 full runs (up to 2 minutes at 100+ players).
Part 1 · What is being optimized

1 What is fixed and what can change

With P players there are T = P/4 tables and P−1 rounds. The seed decides the foursome each player is in, every round. That part is never touched, because it is what guarantees everyone partners each other player once and opposes them twice.

Two things are free:

  • Table labels. In each round, which foursome sits at table 1, which at table 2, and so on. With 5 tables that is 120 choices per round.
  • Round order. The rounds can be played in any order. With 19 rounds there are about 1017 orders.

Changing either one never changes who plays with whom. It only changes where people sit.

Choices per round and in total, for each size:
The search space is far too large to try everything, which is why the optimizer uses guided searches rather than checking every option.

2 The goal and the priorities

Each player plays 4T−1 rounds over T tables, one short of 4 visits per table. So the best possible row for a player is 4 visits at every table except one, which gets 3.

Every schedule is scored in this strict order. A schedule only wins on a later item when it ties on every earlier one:

  1. Rule 3: nobody sits at the same table in two rounds in a row.
  2. Extremes: cells with 0, 1, 6 or more visits.
  3. 2s: cells with 2 visits.
  4. Distance from ideal: the sum of (visits−4)², minus one per player. This is 0 only when every player is all 4s and one 3, and it grows with every 5 and every extra 3.
One 20-player row (5 tables, 19 rounds) and its distance from ideal. Click a cell to move a visit from it to the next table:
Colours match the player-table grids in the optimizer and the tournament creator.
Part 2 · The two stages

3 Stage 1 Beam search

For a fixed round order, Stage 1 labels the tables one round at a time. In each round it only considers labels where nobody returns to the table they just left, so Rule 3 can never be broken.

Picking the best label for each round on its own quickly paints itself into a corner. So it keeps several partial schedules alive at once (the beam, up to a few hundred wide), extends each of them, and keeps only the most promising. "Promising" means every player's visits are on pace to end near the even share.

Round order matters a lot with few tables, because it decides how much freedom Rule 3 leaves. So around the labelling there is a second loop: swap or move a round, re-run the beam, and keep the new order if it is no worse. Each new attempt starts from the best order so far with a small shake-up.

Strength: it always produces a clean schedule, and it is very good at removing extremes. Weakness: it commits to early rounds before it knows how later rounds will go, so the final balance is often a few steps from ideal.

Each column is one more round labelled. Blue nodes are kept in the beam, grey ones are pruned. Only labels that respect Rule 3 are ever created.

4 Stage 2 Annealing

Stage 2 works on a complete schedule and changes the round order and the labels together. Millions of times per second it tries one of two small changes:

  • Swap two tables in one round: two foursomes trade table numbers.
  • Reverse a stretch of rounds: for example rounds 5–11 played backwards. Only the two ends get new neighbours, so this is cheap to check.

A change that improves the score is always accepted. A change that makes it worse is sometimes accepted too, more often early on. This is simulated annealing, named after cooling metal slowly so it settles into a strong structure. Accepting some bad moves early lets the search climb out of dead ends that a strictly downhill search would get stuck in.

The temperature controls how willing it is to accept a worse move. It starts high and falls steadily, so the search gradually turns into pure improvement.

Chance of accepting a move that makes the score worse:
Chance = e−worsening/temperature. The temperature falls from 6 to 0.15 over a run.

5 How Stage 2 handles Rule 3

With only 5 or 6 tables, Rule 3 is very tight. A foursome whose four players came from four different tables last round has only one or two tables left to go to. If Stage 2 refused every move that broke Rule 3, it would almost never be able to move at all.

So during the search Rule 3 is a penalty, not a wall: each repeat costs a set number of points, and the search may pass through schedules with a few repeats on its way to a better one.

  1. Main phase: balance and repeats are traded off while the temperature falls.
  2. Quench: a final, cold phase doubles the repeat penalty again and again until the repeats are squeezed out.
  3. Only clean schedules count. Throughout the run it remembers the best schedule seen with zero repeats. A schedule with even one repeat is never the answer.

Each Stage 2 session makes several runs from random starts: a few seconds each up to about 60 players, growing to 30 seconds at 148, because a big schedule needs a longer run to cool properly. If a run ends without any clean schedule, the next run uses a higher repeat penalty; if it succeeds, the penalty eases a little so the balance gets more weight.

Points per cell that Stage 2 minimizes (plus the repeat penalty):

The extra points for 2s and for 0/1/6+ make Stage 2 follow the same priority order as the final score, so it doesn't trade an extreme for a slightly better average.

Starting repeat penalty: 12 points with 5 tables, 10 with 6, and 6 with 7 or more.
Part 3 · What to expect

6 Typical results

Single test runs in the browser, all with zero Rule 3 repeats:

PlayersAfter Stage 1
2s or 6s / distance
After Stage 2
207 / 54kept Stage 1
247 / 727 / 70
320 / 920 / 70

Runs vary a lot, so treat these as examples, not averages. At 20 players Stage 2 found a result closer to ideal (50) but with more 2s, so the priorities kept Stage 1's answer.

Stage 2 helps most from about 32 players up, where there are enough tables for Rule 3 to leave room to manoeuvre. With 5–6 tables Stage 1 is often already as good.

Even the best schedules have only some players on the exact 4s-and-one-3 row. A computer proof shows the full pattern for every player is impossible at 12 and 16 players, even ignoring Rule 3. At 20 players an 8-minute exhaustive search couldn't decide either way, and the best found without Rule 3 was a distance of 26. So the goal is "as close as possible", not perfect.

If the result is not good enough, run the optimizer again or allow more attempts. Every run starts from fresh random choices, so a second run can land somewhere better.

Try it

Open the seeder & optimizer, pick a size, generate the rounds and press Optimize Schedule. The progress box shows Stage 1's attempts, then a Stage 2 section with the run number, Stage 1's result and the best annealing result so far. The last line says whether Stage 2 improved the schedule.