server/models/cpuPlayer.js
// 3. not many cards of different sizes left (specified by 'minCardGroupCount')
3. not many cards of different sizes left (specified by 'minCardGroupCount')
3 . not many cards of different sizes left ( specified by ' minCardGroupCount ' )
makeHitDecision(cardGroupsCount, cardsToHit, opponentCardCount, isRevolution) {
    if (cardsToHit.length > 0 && cardsToHit.length < 4 && cardGroupsCount >= this._conf.minCardGroupCount &&
      opponentCardCount >= this._conf.minOpponentCardCount) {
      let sum = this.hand.reduce((sum, card) => sum + CardHelper.getRealValue(card, isRevolution), 0);
      let average = 0;
      if (this._conf.calculateAverageAfter) {
        let cardsToHitSum = cardsToHit.reduce((sum, card) => sum + CardHelper.getRealValue(card, isRevolution), 0);
        average = (sum - cardsToHitSum) / (this.hand.length - cardsToHit.length);
      }
      else {
        average = sum / this.hand.length;
      }
      let averageFactor = !isRevolution ? (8 - average) / this._conf.avgScaleFactor :
        (average - 7) / this._conf.avgScaleFactor;
      let realValue = CardHelper.getRealValue(cardsToHit[0], isRevolution);
      let valueFactor = !isRevolution ? realValue - 1 : 14 - realValue;
      valueFactor = (valueFactor / this._conf.valueScaleFactor) - (6.5 / this._conf.valueScaleFactor);
      if (Math.random() < valueFactor + averageFactor) {
        return false;
      }
    }
    return true;
  }
makeHitDecision ( cardGroupsCount , cardsToHit , opponentCardCount , isRevolution ) { if ( cardsToHit . length > 0 && cardsToHit . length < 4 && cardGroupsCount >= this . _conf . minCardGroupCount && opponentCardCount >= this . _conf . minOpponentCardCount ) { let sum = this . hand . reduce ( ( sum , card ) => sum + CardHelper . getRealValue ( card , isRevolution ) , 0 ) ; let average = 0 ; if ( this . _conf . calculateAverageAfter ) { let cardsToHitSum = cardsToHit . reduce ( ( sum , card ) => sum + CardHelper . getRealValue ( card , isRevolution ) , 0 ) ; average = ( sum - cardsToHitSum ) / ( this . hand . length - cardsToHit . length ) ; } else { average = sum / this . hand . length ; } let averageFactor = ! isRevolution ? ( 8 - average ) / this . _conf . avgScaleFactor : ( average - 7 ) / this . _conf . avgScaleFactor ; let realValue = CardHelper . getRealValue ( cardsToHit [ 0 ] , isRevolution ) ; let valueFactor = ! isRevolution ? realValue - 1 : 14 - realValue ; valueFactor = ( valueFactor / this . _conf . valueScaleFactor ) - ( 6.5 / this . _conf . valueScaleFactor ) ; if ( Math . random ( ) < valueFactor + averageFactor ) { return false ; } } return true ; }
3. not many cards of different sizes left (specified by 'minCardGroupCount')
3 . not many cards of different sizes left ( specified by ' minCardGroupCount ' )
// Calculate average by average rule // Calculate hitting probability by the "goodness" of the hand (value average) // Calculate hitting probability by the "goodness" of the cards to hit (value) // The final probability is sum of the two factors