Constructor
new GenerationRunner(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.numGenerations
: a number representing the number of generations that the tournament will last. Defaults to 100.numCopies
: a number representing the number of copies of each strategy to include in the initial generation.
Parameters:
Name | Type | Description |
---|---|---|
opts |
Object | Options object. |
- Source:
Methods
getCopiesInGeneration(name, generation) → {Number}
Returns the number of copies of a strategy in a given generation (the current one, by default).
Parameters:
Name | Type | Description |
---|---|---|
name |
String | The name of a strategy. |
generation |
Array | The generation of copies to examine. |
- Source:
Returns:
Number of copies of the strategy in the generation.
- Type
- Number
getNextGeneration(generation, hiScore, loScore)
Returns the next generation of the population, by eliminating a member with the lowest score, and adding a copy of a member with the highest score.
Parameters:
Name | Type | Description |
---|---|---|
generation |
Array | A list of names of strategies. |
hiScore |
Number | The name of the strategy with the highest score |
loScore |
Number | [description] |
- Source:
run() → {Object}
Run round robin matches for each generation. At the end of each set of matches, a winner gets a copy, and a loser leaves the island.
- Source:
Returns:
Tournament: { participants, generations, matches, results }
- Type
- Object
scoreHiLo(matches) → {Object}
Reports the highest and lowest scores within a group of matches.
Parameters:
Name | Type | Description |
---|---|---|
matches |
Array | An array of matches, as |
- Source:
Returns:
The scores: { hi: Number, lo: Number, winner: String, loser: String }
- Type
- Object