/sgp

Pairings generator for mahjong tournaments based on a solver of the Social Golfer Problem for cases where p=4

Primary LanguagePython

sgp

SGP is a pairings generator for mahjong tournaments. It guarantees that no two players will play with each other more than once and spreads starting seats evenly. It also does its best to avoid having players sit at the same table more than once.

Usage

sgp.py [Number of tables] [Number of rounds¹] [Threshold²]

¹ also known as hanchans

² Explained in Procedure/Assigning table numbers

Procedure

Choosing tables

The program starts by generating possible tables and by randomly choosing and discarding tables that are no longer possible constructs the basic framework for the pairings. This part is equivalent to solving the Social Golfer Problem for given g (number of tables) and w (number of rounds) and p = 4.

Assigning starting seats

Next the program randomises starting seats at all tables and gradually rearranges the seats so that each player gets each seat the same number of times (or as close to that as possible if the number of rounds is not divisible by 4).

Assigning table numbers

Finally the program rearranges the order of the tables in each round to minimise the number of times a player sits at the same table with the same set. It outputs the pairings once the variable used to measure this falls below the threshold with an option to continue its work to improve the pairings by setting a lower threshold. A threshold of 0 means that every player will play each game at a different table.

While this part is not very important, it minimises the chance of a player learning to recognise defective or marked tiles in a given set. If a non-standard set (or sets) has to be used, it minimises the number of games a player would have to play using it.

Note that since the program picks tables randomly, it can happen that it's impossible to improve the generated pairings, so you might need to run it several times before you get a desired result.

Sample tournament

60 players (15 tables), 8 rounds

https://docs.google.com/spreadsheets/d/1gpOJbtK8qj8PUndqdF15SFWOScX_oCKBIfSsUA0kJ-8

Players

In this tab, the left table includes the list of players with the starting numbers they drew, the right table is the same list ordered by starting number.

Pairings

From left to right, there is a table generated by the program, a table of starting seats for each player in each round, a table of table numbers and a table with both table numbers and kanji representing the starting seats.

Opponents

A table showing whether two players will play with each other, and if so in which round.

All tables

A table listing players' names with their seats for all tables and all rounds that can be printed and put on a wall for reference.