thlorenz / pec

Poker equity calculator. Compares two combos or one combo against a range to compute winning equity.
https://thlorenz.github.io/pec
MIT License
18 stars 6 forks source link

Uncaught TypeError: Cannot read property of undefined when attempting to run hand vs range on board #2

Open tiltmine opened 5 years ago

tiltmine commented 5 years ago

Trying to run: QhQs vs. Range: 88+,A9s+,KTs+,QTs+,JTs,T9s,98s,ATo+,KJo+,QJo on Flop: Jd,6h,4h

I am using the webworker-board.js example. However after one or two calls to onupdate() I always see the following error:

Sample output:

    <h5>Combo: QhQs vs. Range: 88+,A9s+,KTs+,QTs+,JTs,T9s,98s,ATo+,KJo+,QJo on Flop: Jd,6h,4h</h5>
    <table>
      <thead>
        <tr>
          <td>Combo</td>
          <td>Win</td>
          <td>Loose</td>
          <td>Tie</td>
          <td>Iterations</td>
        </tr>
      </thead>
      <tbody>
        <tr>
          <td>All</td>
          <td>72.15%</td>
          <td>24.33%</td>
          <td>3.53%</td>
          <td>100</td>
        </tr>
      </tbody>
    </table>

blob:null/35c443c3-1dcb-4400-8133-b2baaa8ee4dd:1409 Uncaught TypeError: Cannot read property '3' of undefined
    at hash_quinary (blob:null/35c443c3-1dcb-4400-8133-b2baaa8ee4dd:1409)
    at evaluate_7_cards (blob:null/35c443c3-1dcb-4400-8133-b2baaa8ee4dd:1162)
    at compareTwoWithBoardExpanded (blob:null/35c443c3-1dcb-4400-8133-b2baaa8ee4dd:11976)
    at compareTwoWithBoard (blob:null/35c443c3-1dcb-4400-8133-b2baaa8ee4dd:11985)
    at raceCodesRandomForBoard (blob:null/35c443c3-1dcb-4400-8133-b2baaa8ee4dd:12101)
    at _raceCodesForBoard (blob:null/35c443c3-1dcb-4400-8133-b2baaa8ee4dd:12113)
    at _raceRangeCodesForBoard (blob:null/35c443c3-1dcb-4400-8133-b2baaa8ee4dd:12144)
    at raceRangeCodesForBoard (blob:null/35c443c3-1dcb-4400-8133-b2baaa8ee4dd:12162)
    at _raceRangeForBoard (blob:null/35c443c3-1dcb-4400-8133-b2baaa8ee4dd:12217)
    at raceRangeForBoard (blob:null/35c443c3-1dcb-4400-8133-b2baaa8ee4dd:12243)

If I set board to null, it works.

Code to reproduce (just the standard webworker-board.js)

'use strict'

const { rates } = require('../')
const backgroundWorker = require('../pec.background')
const { expandRange, arryifyCombo } = require('../test/util/util')
const assert = require('assert')

const worker = backgroundWorker(onupdate)

const range = '88+,A9s+,KTs+,QTs+,JTs,T9s,98s,ATo+,KJo+,QJo'
const combo = 'QhQs'
const expandedRange = expandRange(range)
const expandedCombo = arryifyCombo(combo)
const board = 'Jd 6h 4h'.split(' ')

const trackCombos = false
const raceId = worker.raceRange(expandedCombo, expandedRange, 1E6, trackCombos, board)

function onupdate({ win, loose, tie, iterations, combos, uid }) {
  assert.equal(raceId, uid, 'uid in response needs to match id of initiated race')
  const { winRate, looseRate, tieRate } = rates({
      win
    , loose
    , tie
    , combos
  })

  console.log(`
    <h5>Combo: ${combo} vs. Range: ${range} on Flop: ${board}</h5>
    <table>
      <thead>
        <tr>
          <td>Combo</td>
          <td>Win</td>
          <td>Loose</td>
          <td>Tie</td>
          <td>Iterations</td>
        </tr>
      </thead>
      <tbody>
        <tr>
          <td>All</td>
          <td>${winRate}%</td>
          <td>${looseRate}%</td>
          <td>${tieRate}%</td>
          <td>${iterations}</td>
        </tr>
      </tbody>
    </table>
  `)
}
tiltmine commented 5 years ago

Still haven't found a way around this unfortunately. Is this project currently active / being maintained?