Options
All
  • Public
  • Public/Protected
  • All
Menu

ArkhamOdds

Index

Type aliases

OddsFn

OddsFn: function

Type declaration

OutcomeFunction

OutcomeFunction: function

An outcome function determine success based of the tokens pulled. The function is passed the mapping of token effects and the bag in case they are needed to determine success.

The simplest example just check whether a particular token was pulled:

const elderSignPulled = (tokensPulled) => {
  return tokensPulled[0] === ArkhamOdds.Token.ELDER_SIGN;
}

You can return an outcome function from another function :

const pulledAToken = (token) => {
  return (tokensPulled) => {
    return tokensPulled[0] === token;
  }
}

A more complex example includes the token effects:

const isSuccessWhenOverByTwo = (tokensPulled, tokenEffects) => {
  return tokenEffects.isSuccess(tokensPulled, 2);
}

See TokenEffects.

Finally, some complex cases may require access to the bag. For example an outcome function for Recall the Future may use the bag composition to determine which token to name based on bag composition (see recallTheFuture).

param

The tokens pulled from the bag.

param

Mapping of token effects

param

The bag from which the tokens were pulled.

Type declaration

TokenEffectMapping

TokenEffectMapping: [Token, TokenEffect]

Variables

Const BadTokens

BadTokens: Token[] = [Token.SKULL,Token.CULTIST,Token.TABLET,Token.ELDER_THING,Token.AUTOFAIL]

List of 'bad' tokens, tokens generally triggering bad effects.

Const DefaultTokenEffects

DefaultTokenEffects: TokenEffects = new TokenEffects([[Token.PLUS_ONE, new Modifier(1)],[Token.PLUS_ONE, new Modifier(1)],[Token.ZERO, new Modifier(0)],[Token.MINUS_ONE, new Modifier(-1)],[Token.MINUS_TWO, new Modifier(-2)],[Token.MINUS_THREE, new Modifier(-3)],[Token.MINUS_FOUR, new Modifier(-4)],[Token.MINUS_FIVE, new Modifier(-5)],[Token.MINUS_SIX, new Modifier(-6)],[Token.MINUS_SEVEN, new Modifier(-7)],[Token.MINUS_EIGHT, new Modifier(-8)],[Token.AUTOFAIL, new Autofail()],[Token.BLESS, new Modifier(2, true)],[Token.CURSE, new Modifier(-2, true)]])

Functions

allCombinations

  • allCombinations<T>(elems: T[]): T[][]
  • Type parameters

    • T

    Parameters

    • elems: T[]

    Returns T[][]

arrayEquals

  • arrayEquals<T>(a: T[], b: T[]): boolean
  • Compare 2 arrays using ===. No deep comparaison.

    Type parameters

    • T

    Parameters

    • a: T[]

      First array

    • b: T[]

      Second array

    Returns boolean

    True if a and b contains the same values in the same order.

cartesianProduct

  • cartesianProduct<T>(...sets: T[][]): T[][]
  • Type parameters

    • T

    Parameters

    • Rest ...sets: T[][]

    Returns T[][]

chooseTokenForRecallTheFuture

  • chooseTokenForRecallTheFuture(skillMinusDifficulty: number, bag: Bag, tokenEffects: TokenEffects): Token | null
  • Choose the right token to call with Recall the Future which is, among tokens that can be turned to success using the +2 bonus, the one which has the most occurrences in the bag. Note that it will take into account redraw tokens. For example, when testing at -2, it will not choose -3 even though there is a Bless token (+2, redraw) in the bag.

    Parameters

    • skillMinusDifficulty: number

      value and the difficulty.

    • bag: Bag

      The Chaos bag

    • tokenEffects: TokenEffects

      The token effects mapping.

    Returns Token | null

    The best token to call or null if there is none.

combinations

  • combinations<T>(k: number, elems: T[]): T[][]
  • Returns combinations of elements from an array.

    Type parameters

    • T

    Parameters

    • k: number

      The number of elements in each combination.

    • elems: T[]

      The array of elements to pull from.

    Returns T[][]

    All possible combinations of k elements among elems.

containsAtLeastOneAmong

  • containsAtLeastOneAmong<T>(elements: T[], elementsSearched: T[]): boolean
  • Check if a list of elements contains at least one of the elements provided as second argument.

    Type parameters

    • T

    Parameters

    • elements: T[]

      The list of elements to check.

    • elementsSearched: T[]

      The list of elements to look for.

    Returns boolean

    True if the list provided as first argument contains at least one of the elements provided as second argument.

containsNoneOf

  • containsNoneOf<T>(elements: T[], elementsSearched: T[]): boolean
  • Check if a list of elements does not contains any of the elements provided as second argument.

    Type parameters

    • T

    Parameters

    • elements: T[]

      The list of elements to check.

    • elementsSearched: T[]

      The list of elements to look for.

    Returns boolean

    True if the list provided as first argument does contains not contain any of the elements provided as second argument.

darkProphecy

  • Determine success using Dark Prophecy.

    Parameters

    • skillMinusDifficulty: number

      The difference between the total skill value and the difficulty.

    Returns OutcomeFunction

    An outcome function determining success.

drawFromBag

  • drawFromBag(numTokensPulled: number, bag: Bag, outcomes?: TokenEffects): object[]
  • Return all possible sets of n tokens that can be pulled from the bag along with the odds of pullingthis particular set among all possible sets. For exemple, if drawing only 1 token from a bag containing only a +1 token and 2 -1 token, the result will be:

    • +1 with a 0.33 odds
    • -1 with a 0.66 odds

    Parameters

    • numTokensPulled: number

      The number of tokens simultaneously pulled from the bag.

    • bag: Bag

      The bag from which the tokens are pulled.

    • Optional outcomes: TokenEffects

      The token effects if needed (which is true if some of them have redraw effects).

    Returns object[]

    []} The list of possible pulls along with their odds.

factorial

  • factorial(n: number): number
  • Compute the fractional n!

    Here we are using an iterative version of this function for better performance over a recursive version.

    Parameters

    • n: number

      The number to compute the factorial from

    Returns number

    The result of n!

flatten

  • flatten<T>(elems: T[][]): T[]
  • Type parameters

    • T

    Parameters

    • elems: T[][]

    Returns T[]

gcd

  • gcd(a: number, b: number): number
  • Parameters

    • a: number
    • b: number

    Returns number

getPossiblePullsWithOdds

  • Return all possible sets of n tokens that can be pulled from the bag along with the odds of pullingthis particular set among all possible sets. For exemple, if drawing only 1 token from a bag containing only a +1 token and 2 -1 token, the result will be:

    • +1 with a 0.33 odds
    • -1 with a 0.66 odds

    Parameters

    • numTokensPulled: number

      The number of tokens simultaneously pulled from the bag.

    • bag: Bag

      The bag from which the tokens are pulled.

    • Optional outcomes: TokenEffects

      The token effects if needed (which is true if some of them have redraw effects).

    Returns PullWithOdds[]

    The list of possible pulls along with their odds as fractions.

jacqueline

  • Determine success using Jacqueline Fine's ability to draw 3 tokens and cancel 2 non-tentacle tokens or a tentacle token.

    Parameters

    • skillMinusDifficulty: number

      The difference between the total skill value and the difficulty.

    Returns OutcomeFunction

    An outcome function determining success.

Const odds

  • Compute the odds of a particular outcome when pulling tokens from the bag.

    The outcome function is called for each possible combination of numTokens from the bag and return true or false wether this specific combination is a success or not. This function is called with first argument being the combination (it will contain exactly numTokens tokens), second optional argument being the effects of the tokens and third optional argument being the Chaos bag.

    The simplest outcome function is checking if a particular token was pulled:

    function pulledASkull(tokensPulled) {
      return tokensPulled[0] === ArkhamOdds.Token.SKULL;
    }

    Using the token effects mapping, you can check if the skill test is a success when the total skil vallue is 2 above the difficulty.

    function isSuccessWhenTwoAbove(tokensPulled, tokenEffects) {
      return tokenEffects.isSuccess(tokensPulled, 2);
    }

    Parameters

    • numTokensPulled: number

      The number of tokens simultaneously pulled from the bag.

    • bag: Bag

      The bag from which the tokens are pulled.

    • outcomes: TokenEffects

      The token effects.

    • outcomeFunction: OutcomeFunction

      The outcome function returning true if the pulled tokens represent a desired outcome and false otherwise. The first argument passed to the function are the tokens pulled, the second is the token effects map and the third is the bag. The outcome function should always assume that redraw tokens are counted and that pulled tokens contains the result of redrawing.

    Returns number

    The odds of the desired outcome.

oddsOfCombination

  • oddsOfCombination(totalNumberOfTokens: number, numberOfTokensInCombination: number, numberOfNonRedrawTokensInCombination: number): Fraction
  • Compute the odds of a particular combination of tokens based on how many tokens are not "redraw" tokens. It took me a lot of time to get this formula right. Many thanks to those who helped me get it.

    Parameters

    • totalNumberOfTokens: number

      The total number of tokens in the bag

    • numberOfTokensInCombination: number

      The number of tokens in the combination

    • numberOfNonRedrawTokensInCombination: number

      The number of tokens in this combination that are not "redraw" tokens

    Returns Fraction

    The odds of this combination

Const oddsWithRedraw

  • Similar to odds but this time putting tokens back into the bag between each pull.

    It should be used for abilities like Wendy's:

    let wendyOdds = ArkhamOdds.oddsWithRedraw(
      2, theBag, theEffects,
      ArkhamOdds.successChoosingBest(0));

    TODO Update this function to account for tokens with a redraw effect.

    Parameters

    • numTokensPulled: number

      The number of tokens sequentially pulled from the bag while putting them back in between each pull..

    • bag: Bag

      The bag from which the tokens are pulled.

    • outcomes: TokenEffects
    • outcomeFunction: OutcomeFunction

      The outcome function returning true if the pulled tokens represent a desired outcome and false otherwise. The first argument passed to the function are the tokens pulled, the second is the token effects map and the third is the bag.

    Returns number

    The odds of the desired outcome.

oliveMcBride

  • Choose the 2 best tokens.

    Parameters

    • skillMinusDifficulty: number

      The difference between the total skill value and the difficulty.

    Returns OutcomeFunction

    An outcome function determining if the two chosen tokens result in a success.

oliveMcBrideAndWinchesterDoing1Damage

  • oliveMcBrideAndWinchesterDoing1Damage(skillMinusDifficulty: number): OutcomeFunction
  • Determine success and doing exactly 3 damage using .35 Winchester and Olive McBride.

    Parameters

    • skillMinusDifficulty: number

      The difference between the total skill value and the difficulty.

    Returns OutcomeFunction

    An outcome function determining success.

oliveMcBrideAndWinchesterDoing3Damage

  • oliveMcBrideAndWinchesterDoing3Damage(skillMinusDifficulty: number): OutcomeFunction
  • Determine success and doing exactly 3 damage using .35 Winchester and Olive McBride.

    Parameters

    • skillMinusDifficulty: number

      The difference between the total skill value and the difficulty.

    Returns OutcomeFunction

    An outcome function determining success.

oliveMcBrideWithSkull

  • Choose a Skull if able and the best of remaining tokens.

    Parameters

    • skillMinusDifficulty: number

      The difference between the total skill value and the difficulty.

    Returns OutcomeFunction

    An outcome function determining if the tokens include a Skull and that this Skull + the best of remaining tokens result in a success.

recallTheFuture

  • Determine success using Recall the Future. The strategy applied for Recall the Future is the following :

    • determine which tokens can be turned from failure to success using the +2 bonus from Recall the Future
    • choose the token with the most occurrences in the bag

    Parameters

    • skillMinusDifficulty: number

      The difference between the total skill value and the difficulty.

    Returns OutcomeFunction

    An outcome function determining success.

removeFirst

  • removeFirst<T>(elems: T[], elem: T): T[]
  • Returns a new array with the first occurrence of an element removed from the array passed.

    Type parameters

    • T

    Parameters

    • elems: T[]

      The original array.

    • elem: T

      The element to remove

    Returns T[]

    A new array with the element removed if original array contained it.

replace

  • replace<T>(elems: T[], idx: number, elem: T): T[]
  • Returns a new array with element at index idx replaced with elem.

    Type parameters

    • T

    Parameters

    • elems: T[]

      The original array.

    • idx: number

      The index at which to replace.

    • elem: T

      The element to place at the specified index.

    Returns T[]

    A new array with the element replaced.

ritualCandles

success

  • Basically determine success based on difference between skill value and difficulty.

    Parameters

    • skillMinusDifficulty: number

      The difference between the total skill value and the difficulty.

    Returns OutcomeFunction

    An outcome function determining success.

successChoosingBest

  • Determine success when pulling several tokens and choosing the best to resolve and ignore to others.

    Parameters

    • skillMinusDifficulty: number

      The difference between the total skill value and the difficulty.

    Returns OutcomeFunction

    An outcome function determining success.

tails

  • tails<T>(elems: T[]): T[][]
  • Type parameters

    • T

    Parameters

    • elems: T[]

    Returns T[][]

toTokens

  • toTokens(tokenList: string): Token[]
  • internal

    A function to facilitate the declaration of bag composition.

    Parameters

    • tokenList: string

      The comma-separated list of tokens.

    Returns Token[]

    The array of tokens parsed from the string.

winchesterDoing1Damage

  • Determine success and doing exactly 1 damage using .35 Winchester.

    Parameters

    • skillMinusDifficulty: number

      The difference between the total skill value and the difficulty.

    Returns OutcomeFunction

    An outcome function determining success.

winchesterDoing3Damage

  • Determine success and doing exactly 3 damage using .35 Winchester.

    Parameters

    • skillMinusDifficulty: number

      The difference between the total skill value and the difficulty.

    Returns OutcomeFunction

    An outcome function determining success.

Object literals

Const Bags

Bags: object

Bag compositions for the different campaigns.

CarnevaleOfHorrors

CarnevaleOfHorrors: object

Carnevale of Horrors

Hard

Hard: Token[] = toTokens("+1, 0, 0, 0, -1, -1, -3, -4, -5, -6, -7, Skull, Skull, Skull, Cultist, Tablet, Elder thing, Autofail, Elder sign")

Standard

Standard: Token[] = toTokens("+1, 0, 0, 0, -1, -1, -1, -2, -3, -4, -6, Skull, Skull, Skull, Cultist, Tablet, Elder thing, Autofail, Elder sign")

CurseOfTheRougarou

CurseOfTheRougarou: object

Curse of the Rougarou

Hard

Hard: Token[] = toTokens("+1, 0, 0, 0, -1, -1, -1, -2, -2, -3, -3, -4, -4, -5, -5, -6, -8, Skull, Skull, Skull, Cultist, Cultist, Tablet, Elder thing, Autofail, Elder sign")

Standard

Standard: Token[] = toTokens("+1, +1, 0, 0, 0, -1, -1, -1, -2, -2, -3, -3, -4, -4, -5, -6, Skull, Skull, Cultist, Cultist, Tablet, Elder thing, Autofail, Elder sign")

GuardiansOfTheAbyss

GuardiansOfTheAbyss: object

Guardians of the Abyss

Hard

Hard: Token[] = toTokens("+1, 0, 0, -1, -1, -1, -2, -2, -2, -3, -3, -4, -4, -5, -7, Skull, Skull, Skull, Cultist, Tablet, Elder thing, Autofail, Elder sign")

Standard

Standard: Token[] = toTokens("+1, +1, 0, 0, -1, -1, -1, -2, -2, -3, -3, -4, -6, Skull, Skull, Skull, Cultist, Tablet, Elder thing, Autofail, Elder sign")

MurderAtTheExcelsiorHotel

MurderAtTheExcelsiorHotel: object

Guardians of the Abyss

Hard

Hard: Token[] = toTokens("0, -1, -2, -3, -4, -4, -5, -6, Skull, Skull, Cultist, Tablet, Elder thing, Autofail, Elder sign")

Standard

Standard: Token[] = toTokens("+1, 0, -1, -1, -2, -3, -3, -4, Skull, Skull, Cultist, Tablet, Elder thing, Autofail, Elder sign")

NightOfTheZealot

NightOfTheZealot: object

Night of the Zealot

Easy

Easy: Token[] = toTokens("+1, +1, 0, 0, 0, -1, -1, -1, -2, -2, Skull, Skull, Cultist, Tablet, Autofail, Elder sign")

Expert

Expert: Token[] = toTokens("0, -1, -1, -2, -2, -3, -3, -4, -4, -5, -6, -8, Skull, Skull, Cultist, Tablet, Autofail, Elder sign")

Hard

Hard: Token[] = toTokens("0, 0, 0, -1, -1, -2, -2, -3, -3, -4, -5, Skull, Skull, Cultist, Tablet, Autofail, Elder sign")

Standard

Standard: Token[] = toTokens("+1, 0, 0, -1, -1, -1, -2, -2, -3, -4, Skull, Skull, Cultist, Tablet, Autofail, Elder sign")

TheBlobThatAteEverything

TheBlobThatAteEverything: object

The Blob That Ate Everything

Hard

Hard: Token[] = toTokens("0, 0, 0, -1, -1, -2, -3, -4, -5, -6, Skull, Skull, Cultist, Tablet, Elder thing, Autofail, Elder sign")

Standard

Standard: Token[] = toTokens("+1, 0, 0, 0, -1, -2, -2, -3, -4, -5, Skull, Skull, Cultist, Tablet, Elder thing, Autofail, Elder sign")

TheCircleUndone

TheCircleUndone: object

The Circle Undone

Easy

Easy: Token[] = toTokens("+1, +1, 0, 0, 0, -1, -1, -2, -3, Skull, Skull, Autofail, Elder sign")

Expert

Expert: Token[] = toTokens("0, -1, -1, -2, -2, -3, -4, -6, -8, Skull, Skull, Autofail, Elder sign")

Hard

Hard: Token[] = toTokens("0, 0, -1, -1, -2, -2, -3, -4, -5, Skull, Skull, Autofail, Elder sign")

Standard

Standard: Token[] = toTokens("+1, 0, 0, -1, -1, -2, -2, -3, -4, Skull, Skull, Autofail, Elder sign")

TheDreamEatersTheDreamQuest

TheDreamEatersTheDreamQuest: object

The Dream-Eaters : The Dream-Quest

Easy

Easy: Token[] = toTokens("+1, +1, 0, 0, 0, –1, –1, –2, –2, Cultist, Tablet, Tablet, Autofail, Elder sign")

Expert

Expert: Token[] = toTokens("0, –1, –1, –2, –2, –3, –4, –4, –5, –6, –8, Cultist, Tablet, Tablet, Autofail, Elder sign")

Hard

Hard: Token[] = toTokens("0, 0, –1, –1, –2, –2, –3, –3, –4, –5, Cultist, Tablet, Tablet, Autofail, Elder sign")

Standard

Standard: Token[] = toTokens("+1, 0, 0, –1, –1, –2, –2, –3, –4, Cultist, Tablet, Tablet, Autofail, Elder sign")

TheDreamEatersTheWebOfDreams

TheDreamEatersTheWebOfDreams: object

The Dream-Eaters : The Web of Dreams

Easy

Easy: Token[] = toTokens("+1, +1, 0, 0, 0, –1, –1, –1, –2, –2, Skull, Skull, Cultist, Elder thing, Elder thing, Autofail, Elder sign")

Expert

Expert: Token[] = toTokens("0, –1, –1, –2, –2, –3, –3, –4, –4, –5, –6, –8, Skull, Skull, Cultist, Elder thing, Elder thing, Autofail, Elder sign")

Hard

Hard: Token[] = toTokens("0, 0, 0, –1, –1, –2, –2, –3, –3, –4, –5, Skull, Skull, Cultist, Elder thing, Elder thing, Autofail, Elder sign")

Standard

Standard: Token[] = toTokens("+1, 0, 0, –1, –1, –1, –2, –2, –3, –4, Skull, Skull, Cultist, Elder thing, Elder thing, Autofail, Elder sign")

TheDunwichLegacy

TheDunwichLegacy: object

The Dunwich Legacy

Easy

Easy: Token[] = toTokens("+1, +1, 0, 0, 0, -1, -1, -1, -2, -2, Skull, Skull, Cultist, Autofail, Elder sign")

Expert

Expert: Token[] = toTokens("0, -1, -1, -2, -2, -3, -3, -4, -4, -5, -6, -8, Skull, Skull, Cultist, Autofail, Elder sign")

Hard

Hard: Token[] = toTokens("0, 0, 0, -1, -1, -2, -2, -3, -3, -4, -5, Skull, Skull, Cultist, Autofail, Elder sign")

Standard

Standard: Token[] = toTokens("+1, 0, 0, -1, -1, -1, -2, -2, -3, -4, Skull, Skull, Cultist, Autofail, Elder sign")

TheForgottenAge

TheForgottenAge: object

The Forgotten Age

Easy

Easy: Token[] = toTokens("+1, +1, 0, 0, 0, -1, -1, -2, -3, Skull, Skull, Elder thing, Autofail, Elder sign")

Expert

Expert: Token[] = toTokens("0, -1, -2, -2, -3, -3, -4, -4, -6, -8, Skull, Skull, Elder thing, Autofail, Elder sign")

Hard

Hard: Token[] = toTokens("+1, 0, 0, -1, -2, -3, -3, -4, -6, Skull, Skull, Elder thing, Autofail, Elder sign")

Standard

Standard: Token[] = toTokens("+1, 0, 0, 0, -1, -2, -2, -3, -5, Skull, Skull, Elder thing, Autofail, Elder sign")

TheInnsmouthConspiracy

TheInnsmouthConspiracy: object

The Innsmouth Conspiracy

Easy

Easy: Token[] = toTokens("+1, +1, 0, 0, 0, –1, –1, –1, –2, –2, Skull, Skull, Cultist, Cultist, Tablet, Tablet, Elder thing, Elder thing, Autofail, Elder sign")

Expert

Expert: Token[] = toTokens("0, –1, –1, –2, –2, –3, –3, –4, –4, –5, –6, –8, Skull, Skull, Cultist, Cultist, Tablet, Tablet, Elder thing, Elder thing, Autofail, Elder sign")

Hard

Hard: Token[] = toTokens("0, 0, 0, –1, –1, –2, –2, –3, –3, –4, –5, Skull, Skull, Cultist, Cultist, Tablet, Tablet, Elder thing, Elder thing, Autofail, Elder sign")

Standard

Standard: Token[] = toTokens("+1, 0, 0, –1, –1, –1, –2, –2, –3, –4, Skull, Skull, Cultist, Cultist, Tablet, Tablet, Elder thing, Elder thing, Autofail, Elder sign")

TheLabyrinthsOfLunacy

TheLabyrinthsOfLunacy: object

The Labyrinths of Lunacy

Hard

Hard: Token[] = toTokens("+1, 0, –1, –1, –1, –2, –2, –2, –3, –4, –5, –6, Skull, Skull, Autofail, Elder sign")

Standard

Standard: Token[] = toTokens("+1, 0, 0, 0, –1, –1, –1, –2, –2, –3, –4, –5, Skull, Skull, Autofail, Elder sign")

ThePathToCarcosa

ThePathToCarcosa: object

The Path to Carcosa

Easy

Easy: Token[] = toTokens("+1, +1, 0, 0, 0, -1, -1, -1, -2, -2, Skull, Skull, Skull, Autofail, Elder sign")

Expert

Expert: Token[] = toTokens("0, -1, -1, -2, -2, -3, -3, -4, -4, -5, -6, -8, Skull, Skull, Skull, Autofail, Elder sign")

Hard

Hard: Token[] = toTokens("0, 0, 0, -1, -1, -2, -2, -3, -3, -4, -5, Skull, Skull, Skull, Autofail, Elder sign")

Standard

Standard: Token[] = toTokens("+1, 0, 0, -1, -1, -1, -2, -2, -3, -4, Skull, Skull, Skull, Autofail, Elder sign")

Generated using TypeDoc