ffa-tb

FFA tourney with automatic tiebreakers between rounds

FFA-TB

An implementation of tourney. This module is basically FFA interspersed with TieBreaker rounds after each FFA round to avoid the artificial advancer limit in the fixed size FFA tournament.

Use like FFA, but without concern for ties:

var FFA = require('ffa-tb');
var trn = new FFA(16, { sizes: [4, 4], limit: 2 }); // 2+ rounds 
// score trn.matches until trn.stageDone() 
while (!trn.isDone()) {
  // trn will automatically tiebreak for us if needed 
  // or it will present the next round in the FFA tournament as the next stage 
  trn.createNextStage();
  // score trn.matches until trn.stageDone() 
}
trn.complete(); // seal 

In this case tiebreakers will be created when:

  • round 1 -> 2 when we cannot pick the winner of each match in round 1
  • round 2 could not determine top 2 after scoring and asking for next stage

Use like any other tourney, with the initialization parameters being identical to those you'd normally send to ffa:

var FfaTb = require('ffa-tb');
var ffaOpts = { sizes: [4, 4], advancers: [2] }; // 8 players, 2 rounds of 4 players each 
var trn = new FfaTb(8, ffaOpts);
trn.matches; // contains the one in current stage 
[ { id: { s: 1, r: 1, m: 1 }, p: [ 1, 3, 6, 8 ] },
  { id: { s: 1, r: 1, m: 2 }, p: [ 2, 4, 5, 7 ] } ]
trn.score(trn.matches[0].id, [4,3,2,1]);
trn.score(trn.matches[1].id, [4,3,3,1]);
trn.istageDone(); // true 
 
trn.createNextStage(); // can no longer score previous stage - matches updated 
trn.inTieBreaker(); // true 
 
trn.matches; // tiebreaker for hte second match 
[ { id: { s: 2, r: 1, m: 1 }, p: [ 4, 5 ] ]
trn.score(trn.matches[0].id, [1,2]); // 5 beats 4 in tiebreaker 
 
trn.stageDone(); // true 
trn.createNextStage();
trn.inTieBreaker(); // false 
trn.inFFA(); // true 
 
trn.matches; // top 2 from each match in final 
[ { id: { s: 1, r: 1, m: 1 }, p: [ 1, 2, 3, 5 ] } ]

Standard Tourney API. TieBreaker rounds are interspearsed when necessary and entirely determined by if advancers can be chosen unambiguously. Otherwise, the only differences between FFA is that you need to createNextStage occasionally, and that the matches array shifts to reflect the current round (and is thus easier to manage).

Install locally from npm:

$ npm install ffa-tb --save

Install development dependencies

$ npm install

Run the tests

$ npm test

MIT-Licensed. See LICENSE file for details.