# monte-carlo

1.2.0 • Public • Published

# Monte Carlo simulator for real money games

This is a oppinonated framework for calculating chances of outcomes for games based on a simulation. This can be used to model rules and paytables a test them for win rates and average player return.

It's especially useful for games that combine chance elements with skill (like quizzes) and real money gambling and have rules that make it hard to work out the results mathematically.

Uses ES6 and is therefore Node >4.0.0 only.

## Features

• Optimised for speed
• Simulates different skill levels (By default 50%, 75% and 100% correct)
• Build-in support for collections and presenting results
• Progress indicator
• Exposed RNG operations (`randomDouble()`, `random(min, max)` and `shuffle(list)`) based on Mersenne Twister for better randomness

## Example

What's the chance of answering N questions correctly in a row if there's a 5% chance of hitting a question that's impossible to answer?

Result:

``````==== 10 questions ====
N = 10000
speed: 8475games/sec, total 1.18sec

== Skill Level: 100% ==

wins: 6014 (60.14%) - 1 in 1.66
payout: £45.15 per game, £75.07 per won game (6014 won games), total of £451483.00 (STDDEV: £34.88)

== Skill Level: 75% ==

wins: 318 (3.18%) - 1 in 31.45
payout: £2.42 per game, £75.95 per won game (318 won games), total of £24151.00 (STDDEV: £18.65)

== Skill Level: 50% ==

wins: 3 (0.03%) - 1 in 3333.33
payout: £0.02 per game, £67.00 per won game (3 won games), total of £201.00 (STDDEV: £1.68)

==== 8 questions ====
N = 10000
speed: 13316games/sec, total 0.751sec

== Skill Level: 100% ==

wins: 6534 (65.34%) - 1 in 1.53
payout: £24.44 per game, £37.40 per won game (6534 won games), total of £244376.00 (STDDEV: £16.65)

== Skill Level: 75% ==

wins: 647 (6.47%) - 1 in 15.46
payout: £2.45 per game, £37.92 per won game (647 won games), total of £24535.00 (STDDEV: £12.68)

== Skill Level: 50% ==

wins: 30 (0.30%) - 1 in 333.33
payout: £0.11 per game, £38.03 per won game (30 won games), total of £1141.00 (STDDEV: £2.99)

==== 8 questions, fixed amounts ====
N = 10000
speed: 14472games/sec, total 0.691sec

== Skill Level: 100% ==

wins: 6655 (66.55%) - 1 in 1.50
payout: £25.24 per game, £37.92 per won game (6655 won games), total of £252381.00 (STDDEV: £35.35)

== Skill Level: 75% ==

wins: 689 (6.89%) - 1 in 14.51
payout: £2.56 per game, £37.16 per won game (689 won games), total of £25602.00 (STDDEV: £17.83)

== Skill Level: 50% ==

wins: 26 (0.26%) - 1 in 384.62
payout: £0.08 per game, £30.58 per won game (26 won games), total of £795.00 (STDDEV: £2.92)
``````

In other words: The game tested isn't a great real money game.

none

## Package Sidebar

### Install

`npm i monte-carlo`

### Repository

github.com/Gamevy/monte-carlo

3

1.2.0