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

pec

v0.7.0

Published

BetterPoker equity calculator. Compares two combos or one combo against a range.

Downloads

7

Readme

pec build status

Poker equity calculator. Compares two combos or one combo against a range to compute winning equity.

const { raceRange, rates } = require('pec')

const combo = [ 'Jh', 'Js' ]
const range = [
  [ 'Kh', 'Ks' ], [ 'Kh', 'Kd' ], [ 'Kh', 'Kc' ],
  [ 'Ks', 'Kd' ], [ 'Ks', 'Kc' ], [ 'Kd', 'Kc' ],
  [ 'Qh', 'Qs' ], [ 'Qh', 'Qd' ], [ 'Qh', 'Qc' ],
  [ 'Qs', 'Qd' ], [ 'Qs', 'Qc' ], [ 'Qd', 'Qc' ]
]

const { win, loose, tie } = raceRange(combo, range, 1E4)
const { winRate, looseRate, tieRate } = rates({ win, loose, tie })

console.log('JJ performs as follows vs. [ KK, QQ ]')
console.log('win: %d%% (%d times)', winRate, win)
console.log('loose: %d%% (%d times)', looseRate, loose)
console.log('tie: %d%% (%d times)', tieRate, tie)
JJ performs as follows vs. [ KK, QQ ]
win: 18.13% (21750 times)
loose: 81.43% (97718 times)
tie: 0.44% (532 times)

For more examples see the tests and the webworker example.

You can launch the web worker via npm install && npm run demo.

Installation

npm install pec

API

BackgroundWorker.raceRange

Parameters

  • combo Array<string> to race i.e. [ 'As', 'Ad' ]
  • total Number the total number of times to race, 100 are processed each time and update invoked until the total is reached
  • trackCombos Boolean? if true the counts for each combos are tracked (optional, default false)
  • board Array<string>? if supplied the range will be raced against subsets boards that include all cards of the given board (optional, default null)

Returns Number the uid generated to identify this background job, the same uid will be included in the message the result to identify it with the job

BackgroundWorker.stop

Stops any races in progress.

createBackgroundWorker

Creates a background worker which uses a web worker under the hood to process race requests.

Parameters

  • update funcion will be called with updates: { win, loose, tie, iterations, uid }

Returns BackgroundWorker backgroundWorker

raceCodesForBoard

Same as @see raceCombosForBoard, except that the combo cards are given as their codes obtained via phe cardCodes.

Parameters

  • combo1
  • combo2
  • times
  • board

raceCodes

Same as @see raceCombos, except that the combo cards are given as their codes obtained via phe cardCodes.

Parameters

  • combo1
  • combo2
  • times

raceRangeCodesForBoard

Same as @see raceRangeForBoard, except that the combo, range cards and board are given as their codes obtained via phe cardCodes.

Parameters

  • comboCodes
  • rangeCodes
  • times
  • trackCombos
  • boardCodes

raceRangeCodes

Same as @see raceRange, except that the combo and range cards are given as their codes obtained via phe cardCodes.

Parameters

  • combo1
  • range
  • times
  • trackCombos

raceCombosForBoard

Races two combos against each other.

Parameters

  • combo1 Array<string> first combo to race i.e. [ 'As', 'Ad' ]
  • combo2 Array<string> second combo to race i.e. [ 'As', 'Ad' ]
  • times Number? the number of times to race, if not supplied combos are races against all possible boards (optional, default null)
  • board Array<string>? omit for preflop, but provide for postflop to race against boards that just add a turn or river card to the given one (optional, default null)

Returns any count of how many times combo1 wins, looses or ties, i.e. { win, loose, tie }

raceCombos

Races two combos against each other.

Parameters

  • combo1 Array<string> first combo to race i.e. [ 'As', 'Ad' ]
  • combo2 Array<string> second combo to race i.e. [ 'As', 'Ad' ]
  • times Number? the number of times to race, if not supplied combos are races against all possible boards (optional, default null)

Returns any count of how many times combo1 wins, looses or ties, i.e. { win, loose, tie }

raceRangeForBoard

Race the given combo vs. the given combo to count number of wins, losses and ties. The boards created for the race will include all cards of the given board.

Parameters

  • combo Array<string> to race i.e. [ 'As', 'Ad' ]
  • range Array<Array<string>> multiple combos to raise against it, i.e. [ [ 'Ks', 'Kd' ], [ 'Qs', 'Qd' ] ]
  • times Number? the number of times to race, if not supplied combos are races against all possible boards (optional, default null)
  • trackCombos Boolean? if true the counts for each combos are tracked (optional, default false)
  • board Array<string>? omit for preflop, but provide for postflop to race against boards that just add a turn or river card to the given one (optional, default null)

Returns any count of how many times the combo wins, looses or ties, i.e. { win, loose, tie }

raceRange

Race the given combo vs. the given combo to count number of wins, losses and ties.

Parameters

  • combo Array<string> to race i.e. [ 'As', 'Ad' ]
  • range Array<Array<string>> multiple combos to raise against it, i.e. [ [ 'Ks', 'Kd' ], [ 'Qs', 'Qd' ] ]
  • times Number? the number of times to race, if not supplied combos are races against all possible boards (optional, default null)
  • trackCombos Boolean? if true the counts for each combos are tracked (optional, default false)

Returns any count of how many times the combo wins, looses or ties, i.e. { win, loose, tie }

rates

Given win, loose and tie count it converts those to winning rates in percent.

Parameters

  • $0 Object
    • $0.win Number number of wins
    • $0.loose Number number of losses
    • $0.tie Number number of ties
    • $0.combos Map<String, Number>? map of counts per combo, if given their rates are calculated as well (optional, default null)

Returns Object win rates `{ winRate, looseRate, tieRate, combos? }

License

MIT