roundrobin

A round-robin scheduler used in different tournaments

npm install roundrobin
1 downloads in the last week
15 downloads in the last month

Round Robin Build Status Dependency Status

A simple round robin match scheduler to aid tournament implementations. The round robin implementation is translated directly from the idea outlined on wikipedia.

Usage

Simply give the number of players (with an optional players array), and it will spit out the array of rounds necessary:

var robin = require('roundrobin');
robin(6);
[ [ [ 1, 6 ], [ 2, 5 ], [ 3, 4 ] ],
  [ [ 1, 5 ], [ 6, 4 ], [ 2, 3 ] ],
  [ [ 1, 4 ], [ 5, 3 ], [ 6, 2 ] ],
  [ [ 1, 3 ], [ 4, 2 ], [ 5, 6 ] ],
  [ [ 1, 2 ], [ 3, 6 ], [ 4, 5 ] ] ]

// or with names supplied
robin(6, ['clux', 'lockjaw', 'pibbz', 'xeno', 'e114', 'eclipse']);
[ [ [ 'clux', 'eclipse' ], [ 'lockjaw', 'e114' ], [ 'pibbz', 'xeno' ] ],
  [ [ 'clux', 'e114' ], [ 'eclipse', 'xeno' ], [ 'lockjaw', 'pibbz' ] ],
  [ [ 'clux', 'xeno' ], [ 'e114', 'pibbz' ], [ 'eclipse', 'lockjaw' ] ],
  [ [ 'clux', 'pibbz' ], [ 'xeno', 'lockjaw' ], [ 'e114', 'eclipse' ] ],
  [ [ 'clux', 'lockjaw' ], [ 'pibbz', 'eclipse' ], [ 'xeno', 'e114' ] ] ]

Installation

Install from npm:

$ npm install roundrobin --save

License

MIT-Licensed. See LICENSE file for details.

npm loves you