# tournamentSelection

> **tournamentSelection**(`random`, `scores`, `selectionSize`, `tournamentSize`, `objective`): readonly `number`\[]

Defined in: [packages/evolution/src/selection.ts:43](https://github.com/jkomyno/knotkit/blob/ef04dc6fd5182dca281abddf3e1dcb13118c15a4/packages/evolution/src/selection.ts#L43)

Select source indices through independent tournaments.

Candidates are distinct inside one tournament, but the same source index may win multiple tournaments. Tied scores retain the first sampled index, which is the lowest source index because `sampleIndices` is canonical. Inputs are not mutated. The result is a new array and randomness is consumed separately for every tournament.

## Parameters

### random

[`RandomSource`](/reference/knotkit/prng/type-aliases/randomsource/)

### scores

readonly `number`\[]

### selectionSize

`number`

### tournamentSize

`number`

### objective

[`Objective`](/reference/knotkit/evolution/type-aliases/objective/)

## Returns

readonly `number`\[]

## Throws

With code `EMPTY_POPULATION` for no scores, `INVALID_SCORE` for a non-finite score, `INVALID_SELECTION_SIZE` for a negative or unsafe selection size, `INVALID_TOURNAMENT_SIZE` for a size outside `1..scores.length`, or `INVALID_OBJECTIVE` for an unsupported objective.

## Throws

With code `INVALID_SOURCE_VALUE` when the random source returns a value outside `[0, 1)`.
