Skip to content
/ pec Public

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

License

Notifications You must be signed in to change notification settings

thlorenz/pec

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

42 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

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

About

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

Resources

License

Stars

Watchers

Forks

Packages

No packages published