Options
All
  • Public
  • Public/Protected
  • All
Menu

Class RandomDevice<Outcome>

A device generating random outcomes with specific odds. For example, a classic 6-sided can be created with the following code:

const d6 = new RandomDevice<number>([
  [1, new Fraction(1, 6)],
  [2, new Fraction(1, 6)],
  [3, new Fraction(1, 6)],
  [4, new Fraction(1, 6)],
  [5, new Fraction(1, 6)],
  [6, new Fraction(1, 6)]
]);

Type parameters

  • Outcome

    The type of the outcome generated from this random device.

Hierarchy

  • RandomDevice

Index

Constructors

Methods

Constructors

constructor

Methods

getOutcomesWithOdds

  • getOutcomesWithOdds(): WithOdds<Outcome[]>[]
  • Get the possible outcomes and odds for this random device.

    Returns WithOdds<Outcome[]>[]

    The possible outcomes (as sets) this random device can generate along with the odds of each outcome.

Generated using TypeDoc