Class: BaseRunner

BaseRunner

Base class for tournament runners.

Constructor

new BaseRunner(opts)

Class constructor. Supported options:

  • participants: an array of strings representing names of participating strategies. Defaults to one instance of each known strategy.
  • numRounds: a number representing the number of rounds in each match of the tournaments. Defaults to 100 +/- 2.
Parameters:
Name Type Description
opts Object

Options object.

Source:
To Do:
  • subclass from https://github.com/clux/tournament LIKE OR DON'T? WHO CARES!

Methods

formatResults(matches) → {Object}

Given match info, format tournament results.

Parameters:
Name Type Description
matches Array

[description]

Source:
Returns:

Array of match results for each participant: [{ score, wins, draws, losses }, ...]

Type
Object

pairings(participants) → {Array}

Get match pairings. Sub-classes MUST implement this method.

Parameters:
Name Type Description
participants Array

A list of names of participating strategies.

Source:
Returns:

An array of arrays of the pairings for each match in the tournament.

Type
Array

play(strat1, strat2) → {Array}

Pit two strategies against each other, returning the choices of each strategy during each round of the match.

Parameters:
Name Type Description
strat1 function

A strategy function.

strat2 function

Another strategy function.

Source:
Returns:

Each player's choices during the round, as [[t, f], [f, t], [...]].

Type
Array

playMatch(pair) → {Object}

Play a match between a given pair of strategies. Returns data about the match including history and score.

Parameters:
Name Type Description
pair Array

A pair of strategy names.

Source:
Returns:

Match: { pair, history, score }

Type
Object

playMatches(participants) → {Array}

Plays all pairings for the given participants, returning an array of matches.

Parameters:
Name Type Description
participants Array

A list of names of participating strategies.

Source:
Returns:

A list of match results: { pair, history, score }

Type
Array

run() → {Object}

Carry out the tournament. Returns the results.

Source:
Returns:

Tournament: { participants, matches, results }

Type
Object

score(history) → {Array}

Tallies each player's score from their actions during the round. Values are derived from Poundstone's 1992 paper.

Parameters:
Name Type Description
history Array

An array of arrays of each player's choices from each round.

Source:
Returns:

Each player's score during the round, as [x, y].

Type
Array