rstt.solver package

Submodules

rstt.solver.solvers module

Solver Module

Solver provide a solve(match: SMatch) method to assign a Score to the match. Typicaly a WIN/LOSE/DRAW in case of ‘versus’ matches

class rstt.solver.solvers.BetterWin(with_draw: bool = False)[source]

Bases: object

BetterWin Solver

Implements a deterministic Score generator. BetterWin always assign a Win to the best (highest level) participant of a match.

Warning

Only Supports Duel at the moment.

Parameters

with_drawbool, optional

Wether a draw should be assigned to the game in case of equals level, by default False. When False, there is a ‘home advantage policy’ meaning that in case of equals levels, the first team of the match wins.

solve(duel: Duel, *args, **kwars) None[source]
class rstt.solver.solvers.BradleyTerry[source]

Bases: ScoreProb

Bradley-Terry model

Implements the famous pairwise model comparaison probabilistic model.

It is a ScoreProb Solver where the probability function that a player A with level a, beats a player B with level b, is defined as

P(A win against B) := a/(a + b)

class rstt.solver.solvers.CoinFlip[source]

Bases: WeightedScore

Random Solver

Behave like a coin flip, a win or a lose is randomly generated with no regards to any Match details.

rstt.solver.solvers.DRAW = [0.5, 0.5]

Default Score Value indicating a ‘draw’ between the two opponents in a ‘versus’ Match

rstt.solver.solvers.LOSE = [0.0, 1.0]

Default Score Value indicating a ‘lose’ for the first memeber of a ‘versus’ Match

class rstt.solver.solvers.LogSolver(base: float | None = None, lc: float | None = None)[source]

Bases: ScoreProb

Elo like Solver

The LogSolver implements a standard reparametrization of the Bradley-Terry model that matches Elo rating system. In practice it is a ScoreProb with a probability function illustrated on wismuth. FOr a player A with level a, and a Player B with level b, it is defined by the logistic function: P(A wins against B) = 1/(1+base^( (b-a) / lc))

Parameters

baseOptional[float], optional

The base in the logistic function, by default 10

lcOptional[float], optional

The constant in the logistic function, by default 400

Note

Default constant in the RSTT package ensure that the LogSolver probabilities matches the expected Score by rstt.ranking.inferer.Elo. Which means that perfectly accurate predictions are possible when combining both in simulation.

class rstt.solver.solvers.ScoreProb(scores: List[list[float]], func: Callable[[Duel], list[float]])[source]

Bases: object

General Purpose Solver

A ScoreProb

Parameters

scoresList[Score]

A list of possible match outcomes.

funcCallable[[Duel], Score]

A function taking as input a Duel and producing Score probabilities

solve(duel: Duel, *args, **kwars) None[source]
rstt.solver.solvers.WIN = [1.0, 0.0]

Default Score Value indicating a ‘win’ for the first memeber of a ‘versus’ Match

class rstt.solver.solvers.WeightedScore(scores: List[list[float]], weights: List[float])[source]

Bases: ScoreProb

Weighted Score assignement

With this Solver, A score is randomly chosed form a list of options based on weighted.

Parameters

scoresList[Score]

A list of possible match outcomes.

weightsList[float]

The corresponding weight associated to each Score.

Raises

ValueError

An error is raised when the scores and weights length are not equal.

rstt.solver.solvers.solve(self, duel: Duel, *args, **kwars) None

Module contents

Solver for simulation

The subpackage implements rstt.stypes.Solver of different models. Solver are responsible to produce a rstt.stypes.Score and assign it to a rstt.stypes.SMatch.

Warning

The current version of RSTT only support Solver for the rstt.game.match.Duel class.

Solver for other match will be added in future version (as will other Match classes).

In the mean time, if you need help to write your own Solver, ask for advise on the RSTT discord

class rstt.solver.BetterWin(with_draw: bool = False)[source]

Bases: object

BetterWin Solver

Implements a deterministic Score generator. BetterWin always assign a Win to the best (highest level) participant of a match.

Warning

Only Supports Duel at the moment.

Parameters

with_drawbool, optional

Wether a draw should be assigned to the game in case of equals level, by default False. When False, there is a ‘home advantage policy’ meaning that in case of equals levels, the first team of the match wins.

solve(duel: Duel, *args, **kwars) None[source]
class rstt.solver.BradleyTerry[source]

Bases: ScoreProb

Bradley-Terry model

Implements the famous pairwise model comparaison probabilistic model.

It is a ScoreProb Solver where the probability function that a player A with level a, beats a player B with level b, is defined as

P(A win against B) := a/(a + b)

class rstt.solver.CoinFlip[source]

Bases: WeightedScore

Random Solver

Behave like a coin flip, a win or a lose is randomly generated with no regards to any Match details.

class rstt.solver.LogSolver(base: float | None = None, lc: float | None = None)[source]

Bases: ScoreProb

Elo like Solver

The LogSolver implements a standard reparametrization of the Bradley-Terry model that matches Elo rating system. In practice it is a ScoreProb with a probability function illustrated on wismuth. FOr a player A with level a, and a Player B with level b, it is defined by the logistic function: P(A wins against B) = 1/(1+base^( (b-a) / lc))

Parameters

baseOptional[float], optional

The base in the logistic function, by default 10

lcOptional[float], optional

The constant in the logistic function, by default 400

Note

Default constant in the RSTT package ensure that the LogSolver probabilities matches the expected Score by rstt.ranking.inferer.Elo. Which means that perfectly accurate predictions are possible when combining both in simulation.

class rstt.solver.ScoreProb(scores: List[list[float]], func: Callable[[Duel], list[float]])[source]

Bases: object

General Purpose Solver

A ScoreProb

Parameters

scoresList[Score]

A list of possible match outcomes.

funcCallable[[Duel], Score]

A function taking as input a Duel and producing Score probabilities

solve(duel: Duel, *args, **kwars) None[source]