npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

r6bg-damage-probabilities

v0.0.2

Published

Functions to calculate damage probabilities in "6: The boardgame" based on the video game "Rainbow 6: Siege"

Downloads

2

Readme

Rainbow 6 Board Game - Damage Probabilities

A library to calculate damage probabilities and simulate damage rolls for "6: The BoardGame" a tabletop game based on video game "Rainbow 6: Siege".

Usage

This section provides examples of how to use the library to calculate probabilities and simulate damage rolls.

Imports

import { getProbabilitiesFromDiceSet } from "r6bg-damage-probabilities";
// or
import { getSampleFromDiceSet } from "r6bg-damage-probabilities";

Simplest use

Probabilities

Get probabilities when throwing 2 yellow dice, 0 orange and 1 red.

getProbabilitiesFromDiceSet({ yellow: 2, orange: 0, red: 1 })

Will return object with the probability of each possible damage outcome

{
  '1': 0.03758,
  '2': 0.1105,
  '3': 0.22241,
  '4': 0.25765,
  '5': 0.22433,
  '6': 0.11133,
  '7': 0.0362
}

Sample roll

Get random damage roll when throwing 1 yellow dice, 1 orange and 2 red.

getSampleFromDiceSet({ yellow: 1, orange: 1, red: 2 });

Will return an array with the example damage roll (It's an array because 3rd parameters let you choose the number of rolls)

[7]

Use with all parameters

Probabilities

Get probabilities when throwing 1 yellow dice, 1 orange and 1 red and 1 orange lightning dice without ignoring protection, using a target with light protection and simulating rolls

const diceSet = {
  yellow: 1,
  orange: 1,
  red: 1,
  yellowLightning: 0, // lightning dice are ignored if target is protected
  orangeLightning: 1, // lightning dice are ignored if target is protected
  redLightning: 0, // lightning dice are ignored if target is protected
  ignoreProtection: false, // if the weapon ignores protection (for example grenades)
};
getProbabilitiesFromDiceSet(
  diceSet, // all weapon characteristics above
  PROTECTION.LIGHT, // 'none'/'light'/'heavy', target's protection
  PROBABILITY_MODE.SIMULATION, // 'simulate'/'maths', Simulate rolls instead of calculating probabilities mathematically
);

This will return the probabilities object:

{
  '0': 0.09431,
  '1': 0.16792,
  '2': 0.23846,
  '3': 0.23927,
  '4': 0.16632,
  '5': 0.07461,
  '6': 0.01911
}

Sample rolls

Get 5 random possible damage rolls when throwing 2 orange dice, 1 red and 1 red lightning without ignoring protection, using a target with no protection

const diceSet = {
  yellow: 0,
  orange: 2,
  red: 1,
  yellowLightning: 0, // lightning dice are ignored if target is protected
  orangeLightning: 0, // lightning dice are ignored if target is protected
  redLightning: 1, // lightning dice are ignored if target is protected
  ignoreProtection: false, // if the weapon ignores protection (for example grenades)
};
getSampleFromDiceSet(
  diceSet, // all weapon characteristics above
  PROTECTION.NONE, // 'none'/'light'/'heavy', target's protection
  5, // Number of rolls to return
);

Will return an array with the example damage rolls

[ 6, 11, 7, 5, 8 ]

Installation

npm i r6bg-damage-probabilities

Additional infos

The game's maximum number of dice in a single roll is 4.

By default, probabilities are calculated mathematically for rolls with 4 dice and fewer, and simulating 100 000 rolls if you use more dice.

You can force using one probability mode or another, but with 10+ dice, the mathematical solution will probably crashes as it was not designed for it.