docs: function randomPairs(settings) {
          var r1, r2;
          var ii, i, len;
          var roundMatches, nMatchesIdx, match, id1, id2, missId;
          var matches, matchesById, sayPartner, doRoles;
          var opts, roles, matchedRoles;
  
          var game, n;
          var nRounds;
  
          // Delete previous results.
          this.lastMatches = null;
          this.lastMatchesById = null;
  
          // Init local variables.
  
          matchesById = {};
  
          sayPartner = 'undefined' === typeof settings.sayPartner ?
              true : !!settings.sayPartner;
  
          doRoles = !!settings.roles;
  
          game = this.node.game;
          n = game.pl.size();
  
          // Settings the number of rounds.
          if ('undefined' !== typeof settings.rounds) {
              nRounds = settings.rounds;
          }
          else {
              nRounds = game.plot.getRound(game.getNextStep(), 'total');
          }
          if (nRounds > n-1) nRounds = n-1;
  
          // Algorithm: random.
          if (settings.match === 'random') {
              if (doRoles) {
                  this.roler.clear();
                  this.roler.setRoles(settings.roles, 2);
                  this.matcher.init({ doRoles: doRoles });
              }
              this.matcher.generateMatches('random', n, {
                  rounds: nRounds,
                  // cycle: settings.cycle,
                  skipBye: settings.skipBye,
                  bye: settings.bye,
                  fixedRoles: settings.fixedRoles,
                  canMatchSameRole: settings.canMatchSameRole
              });
              this.matcher.setIds(game.pl.id.getAllKeys());
              // Generates new random matches for this round.
              this.matcher.match(true);
          }
  
          // Algorithm: round robin (but only if not already initialized
          // or if reInit = true).
          else {
              if (!this.matcher.matches || settings.reInit) {
                  if (doRoles) {
                      this.roler.clear();
                      this.roler.setRoles(settings.roles, 2);
                      this.matcher.init({ doRoles: doRoles });
                  }
                  // Make a manual copy of settings object, and generate matches.
                  this.matcher.generateMatches('roundrobin', n, {
                      rounds: nRounds,
                      cycle: settings.cycle,
                      skipBye: settings.skipBye,
                      bye: settings.bye,
                      fixedRoles: settings.fixedRoles,
                      canMatchSameRole: settings.canMatchSameRole
                  });
                  this.matcher.setIds(game.pl.id.getAllKeys());
                  // Generates matches.
                  this.matcher.match(true);
              }
              // Cycle through the matches, if we do not have enough.
              else if (!this.matcher.hasNext()) {
                  this.matcher.init( { x: null, y: null });
              }
          }
  
          // Get all the matches for round x, and increments x.
          nMatchesIdx = 'number' === typeof this.matcher.x ?
              (this.matcher.x + 1) : 0;
          // This also increments the index matcher.x.
          roundMatches = this.matcher.getMatch(nMatchesIdx);
  
          len = roundMatches.length;
  
          // Contains one remoteOptions object per player.
          matches = ((n % 2) === 0) ?
              new Array((len*2)) :
              (settings.skipBye ? new Array((len*2)-2) : new Array((len*2)-1));
  
          // The id in case the number of player is odd.
          missId = this.matcher.missingId;
  
          matchedRoles = this.roler.getRolifiedMatches();
  
          // While we have matches, send them to clients.
          ii = i = -1;
          for ( ; ++i < len ; ) {
              ii++;
              match = roundMatches[i];
              id1 = match[0];
              id2 = match[1];
  
              // Verify that id1 and id2 are still connected.
              if (!game.pl.exist(id1)) id1 = missId;
              if (!game.pl.exist(id2)) id2 = missId;
  
              // If both id1 and id2 are disconnected, skip matching them.
              if (id1 === id2) {
                  // Reduce matches array length.
                  len--;
                  matches.length--;
                  continue;
              }
  
              if (doRoles) {
                  roles = matchedRoles[nMatchesIdx][i];
  
                  // Prepare options to send to player 1, if role1 is defined.
                  r1 = roles[0];
  
                  if (r1) {
                      if (!sayPartner) {
                          opts = { id: id1, options: { role: r1 } };
                      }
                      else {
                          opts = { id: id1, options: { role: r1, partner: id2 } };
                      }
                      // Add options to array.
                      matches[ii] = opts;
  
                      // Keep reference.
                      matchesById[id1] = opts.options;
                  }
  
                  // Prepare options to send to player 2, if role2 is defined.
                  r2 = roles[1];
  
                  if (r2) {
  
                      // Increment ii index if both r1 and r2 are defined.
                      if (r1) ii++;
  
                      if (!sayPartner) {
                          opts = { id: id2, options: { role: r2 } };
                      }
                      else {
                          opts = { id: id2, options: { role: r2, partner: id1 } };
                      }
                      // Add options to array.
                      matches[ii] = opts;
  
                      // Keep reference.
                      matchesById[id2] = opts.options;
                  }
              }
              else if (sayPartner) {
                  if (id1 !== missId) {
                      opts = { id: id1, options: { partner: id2 } };
                      matches[ii] = opts;
                      matchesById[id1] = opts.options;
                  }
                  if (id2 !== missId) {
                      if (id1 !== missId) ii++;
                      opts = { id: id2, options: { partner: id1 } };
                      matches[ii] = opts;
                      matchesById[id2] = opts.options;
                  }
              }
          }
  
          // Store references.
          this.lastMatches = matches;
          this.lastMatchesById = matchesById;
          this.lastSettings = settings;
  
          return matches;
      }