pec
v0.7.0
Published
BetterPoker equity calculator. Compares two combos or one combo against a range.
Downloads
7
Readme
pec
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 andupdate
invoked until thetotal
is reachedtrackCombos
Boolean? iftrue
the counts for each combos are tracked (optional, defaultfalse
)board
Array<string>? if supplied the range will be raced against subsets boards that include all cards of the given board (optional, defaultnull
)
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, defaultnull
)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, defaultnull
)
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, defaultnull
)
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, defaultnull
)trackCombos
Boolean? iftrue
the counts for each combos are tracked (optional, defaultfalse
)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, defaultnull
)
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, defaultnull
)trackCombos
Boolean? iftrue
the counts for each combos are tracked (optional, defaultfalse
)
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
Returns Object win rates `{ winRate, looseRate, tieRate, combos? }
License
MIT