function splitReturns(comp, cards, i, r, depth) {
    let hand = HAND_STATES[i];
    if(!depth) {
      depth = 1;
    }

    let c = CARD_STATES.indexOf(hand); // Card Index
    // hitReturns is a vector representing the returns of each possible hand after the split
    // ie. pair of 8s -> [return of 10, return of 11, ..., return of soft 19]
    let hitReturns = vmultiply(transitionMatrix(comp)[i], r);
    /*
     * The log2(maxHands) is an approximation that will always give a return below the actual return
     * It assumes that a hand can be split only to a depth of log2(maxHands),
     * however a hand can be split to a further depth if other hands aren't split
     * This approximation is only deals with multiple resplits,
     * and because this is rare, this approximation doesn't affect the return much
     * */
    if(
      params.split.resplit &&
      depth <= Math.log2(params.split.maxHands) &&
      !(hand === ACE && !params.split.resplitAces)
    ) {
      // Important that we shift the comp, or else ten splitting will appear much too advantageous
      comp = pullCard(comp, c, cards.cards);
      cards.cards--;
      // comp[c] is the chance we are able to resplit again
      if(comp[c] > 0) {
        let k = pairIndex(i);
        hitReturns[k] = comp[c] * splitReturns(comp, cards, i, r, depth + 1);
      }
    }
    // Double the return because we increased our bet
    return 2 * vtotal(hitReturns);
  }
/*
   * i is the index of the hand after split
   * ie. if splitting 8s, HAND_STATES[i] = 8
   * r is a vector with the return of each hand for the current dealer card
   * If double after split is allowed, r will be taken from rdM
   * If double after split is not allowed, r will be taken from rM
   * depth=n means we have split n times to reach this hand
   * */
i is the index of the hand after split
ie. if splitting 8s, HAND_STATES[i] = 8
r is a vector with the return of each hand for the current dealer card
If double after split is allowed, r will be taken from rdM
If double after split is not allowed, r will be taken from rM
depth=n means we have split n times to reach this hand
i is the index of the hand after split ie . if splitting 8s HAND_STATES [ i ] = 8 r is a vector with the return of each hand for the current dealer card If double after split is allowed r will be taken from rdM If double after split is not allowed r will be taken from rM depth = n means we have split n times to reach this hand
function splitReturns(comp, cards, i, r, depth) {
    let hand = HAND_STATES[i];
    if(!depth) {
      depth = 1;
    }
    let c = CARD_STATES.indexOf(hand); 
    let hitReturns = vmultiply(transitionMatrix(comp)[i], r);
    if(
      params.split.resplit &&
      depth <= Math.log2(params.split.maxHands) &&
      !(hand === ACE && !params.split.resplitAces)
    ) {
      comp = pullCard(comp, c, cards.cards);
      cards.cards--;
      if(comp[c] > 0) {
        let k = pairIndex(i);
        hitReturns[k] = comp[c] * splitReturns(comp, cards, i, r, depth + 1);
      }
    }
    return 2 * vtotal(hitReturns);
  }
function splitReturns ( comp , cards , i , r , depth ) { let hand = HAND_STATES [ i ] ; if ( ! depth ) { depth = 1 ; } let c = CARD_STATES . indexOf ( hand ) ; let hitReturns = vmultiply ( transitionMatrix ( comp ) [ i ] , r ) ; if ( params . split . resplit && depth <= Math . log2 ( params . split . maxHands ) && ! ( hand === ACE && ! params . split . resplitAces ) ) { comp = pullCard ( comp , c , cards . cards ) ; cards . cards -- ; if ( comp [ c ] > 0 ) { let k = pairIndex ( i ) ; hitReturns [ k ] = comp [ c ] * splitReturns ( comp , cards , i , r , depth + 1 ) ; } } return 2 * vtotal ( hitReturns ) ; }
i is the index of the hand after split
 ie.
i is the index of the hand after split ie .
// Card Index // hitReturns is a vector representing the returns of each possible hand after the split // ie. pair of 8s -> [return of 10, return of 11, ..., return of soft 19] /*
     * The log2(maxHands) is an approximation that will always give a return below the actual return
     * It assumes that a hand can be split only to a depth of log2(maxHands),
     * however a hand can be split to a further depth if other hands aren't split
     * This approximation is only deals with multiple resplits,
     * and because this is rare, this approximation doesn't affect the return much
     * */ // Important that we shift the comp, or else ten splitting will appear much too advantageous // comp[c] is the chance we are able to resplit again // Double the return because we increased our bet