You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Stefano Balietti edited this page Oct 21, 2021
·
2 revisions
status: complete
version: 7.x
Overview
The api is limited to matching players into pairs only.
The only matching algorithm is already implemented is round robin
(also known as perfect stranger), but custom matching algorithms can
be plugged into the api easily.
By default, the specified ids will be randomly placed into the
tournament schedule. However, if a special assignment is required, it
is possible to specify an assigner callback
The assigner callback is called before performing a matching. The
order of the ids inside the array returned by the functions determines
how the players are assigned to the schedule.
Generate the tournament table with a given matching algorithm
(roundrobin is the only option for now), and pass any extra option.
matcher.generateMatches('roundrobin',4);
Set the ids of the players. They will substitute the numbers in the
tournament table.
matcher.setIds(['a','b','c','d'])
Match the ids of the players into the round robin tournament
schedule. By default, the ids are randomly assigned, but other
assignment rules can be defined.
matcher.match();// The whole tournament schedule is defined as follow:[// Round 1.[['a','b'],['c','d']],// Round 2.[['c','b'],['a','d']],// Round 3.[['c','a'],['b','d']]]
Call getMatch to receive the next match.
matcher.getMatch();// Returns ['a', 'b']matcher.getMatch();// Returns ['c', 'd']matcher.getMatch();// Returns ['c', 'b']// When all the matches are exhausted null will be returned