Skip to main content

Compute exact DPS for turn-based games

Project description


Computes the probability mass function for an extended negative binomial distribution essential for accurate DPS calculations in a variety of turn/tick-based games.


Common methods for estimating how long it takes to finish off an opponent in typical hack-and-slash games are inaccurate due to factors like overkill. Those crude calculations are often good enough, but in case they're not you can turn to this library to get an exact answer.


dpsbin requires Python 3 or greater and is available on PyPI.

python -m pip install dpsbin

Alternatively, the latest version can be easily downloaded and installed locally.

git clone
cd dpsbin
python -m pip install -e .

Using dpsbin

The only notable entry point is dpsbin.pmf. Suppose you want to know how many times you'll have to roll a 6-sided die to reach a total of 40 or more.

import dpsbin, numpy as np, math

probs = dpsbin.pmf(6, 40)

# probs[k] is the probability you need to roll k times.
assert math.isclose(np.sum(probs), 1)

# easily find out how many rolls you'll need on average.
avg =, np.arange(len(probs)))

# if you have a 90% chance to miss and not deal the 1d6 damage then
# you can use with_zeros() to translate the old probability mass array
# into one that accounts for zeros. Truncate to only considering up
# to 80 rolls.
hard_to_hit = dpsbin.with_zeros(80, .9, probs)

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

dpsbin-0.0.4.tar.gz (7.2 kB view hashes)

Uploaded source

Built Distribution

dpsbin-0.0.4-py3-none-any.whl (19.9 kB view hashes)

Uploaded py3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page