Full algorithmn of european roulette.
First of all import /roulette-algo.js
to your module and then instanciate a new Roulette
:
import { Roulette, Chip } from 'roulette-algo';
const roulette = new Roulette();
All possible bets are on putOn
object provided in roulette instance, take the example:
roulette.putOn.single(new Chip(10), 15); // Puts a chip 10 on number 15
roulette.putOn.reds(new Chip(1)); // Puts chip 1 on reds
roulette.putOn.zero(new Chip(1)); // Puts chip 1 on zero
roulette.putOn.rightHalf(new Chip(2)); // Puts a chip 2 on numbers 19-36
roulette.putOn.firstTwelve(new Chip(2)); // Puts a chip 2 on numbers 1-12 (1st dozen)
roulette.putOn.double(new Chip(2), 1, 2); // Puts a chip 2 on middle of 1 and 2
roulette.putOn.quarter(new Chip(10), 17, 20, 16, 19); // Puts a chip 10 on middle of 17, 20, 16 and 19
// and so on...
Finally, you just need to spin()
the roulette and get the results:
const results = roulette.spin();
Results is an object returned by the roulette with all results of the "round":
results.number // Roulette drawn number
results.spent; // Amount of chips spent
results.received; // All chips received includes the ones you bet
results.total; // received - spent (Can be negative)
results.hasWon // Boolean, if balance is positive
results.hasLost // Boolean, if balance is negative
results.hasDraw // Boolean, if balance is zero
results.wonBets // List of won bets made
results.betsMade // List of bets made
More than this, the roulette also provide extra features such as the possibility to redo the last bets and double the current ones.
Copies the last bets of the last spin you did:
roulette.redoLastBets();
Doubles the current bets:
roulette.doubleBets();
You can use this to run backtests of strategies. Some examples are in the folder /strategies
where you can find them, use or modify.
To run any of them, (e.g martingale.js) use:
node -r esm martigale.js
All tests are under folder /tests
, every test instanciate a Roulette
and run tests over this.
Tests are integrated with Mocha.
Don't forget to install modules needed first:
npm i
To run tests use
npm test
All the code is made using ECMAScript 6+, if you intend to run it on older versions you may need transpiler like Babel
- Include all JS Docs
- Include out-of-box retro compactibilty with Babel
- Bets by player with full distinction