src/Evaluators/HighHandEvaluator.php
/**
    * Generate a numerical value for hand ranking
    * Used for quicker comparing of hands
    * 
    * @return void
    */
Generate a numerical value for hand ranking
Used for quicker comparing of hands

@return void
Generate a numerical value for hand ranking Used for quicker comparing of hands @return void
protected function computeHandValues(): void
    {
        $numberOfSignificantCards = self::numberOfSignificantCards($this->handRank) - 1;
        $handValueBinary = $handValueWithoutKickersBinary = sprintf("%04d", decbin($this->handRank));
        foreach($this->hand as $index => $card) {
            $handValueBinary .= sprintf("%04d", decbin($card->getValueRank()));
            $handValueWithoutKickersBinary .= ($index <= $numberOfSignificantCards) ? sprintf("%04d", decbin($card->getValueRank())) : '00000000';
        }
        $this->handValue = bindec($handValueBinary);
        $this->handValueWithoutKickers = bindec($handValueWithoutKickersBinary);
    }
protected function computeHandValues ( ) : void { $ numberOfSignificantCards = self :: numberOfSignificantCards ( $ this -> handRank ) - 1 ; $ handValueBinary = $ handValueWithoutKickersBinary = sprintf ( " %04d " , decbin ( $ this -> handRank ) ) ; foreach ( $ this -> hand as $ index => $ card ) { $ handValueBinary .= sprintf ( " %04d " , decbin ( $ card -> getValueRank ( ) ) ) ; $ handValueWithoutKickersBinary .= ( $ index <= $ numberOfSignificantCards ) ? sprintf ( " %04d " , decbin ( $ card -> getValueRank ( ) ) ) : '00000000' ; } $ this -> handValue = bindec ( $ handValueBinary ) ; $ this -> handValueWithoutKickers = bindec ( $ handValueWithoutKickersBinary ) ; }
Generate a numerical value for hand ranking
 Used for quicker comparing of hands
Generate a numerical value for hand ranking Used for quicker comparing of hands
// The hand is sorted with the most significant cards to the front i.e. [14, 12, 10, 6, 5] // https://stackoverflow.com/a/42396124/7095440 // Convert hand to a 44 bit binary // [HAND_RANK Binary] [Card 0 Binary] [Card 1 Binary] [Card 2 Binary] [Card 3 Binary] [Card 4 Binary] // [4 bits] [8 bits] [8 bits] [8 bits] [8 bits] [8 bits] // Card binary is 4 bit binary of Value and 4 bit value of suit.  This was needed for PLO hands where it would stop on the first best hand, but the suits were not in the right order. // Now suits binaries play a factor in to the Cards that are returned for PLO // For certain hand types, only the first n cards are significant // Used when winning hands of the same type were eventually determined by their kicker // so that an appropriate description can be generated // e.g. AAKK8 vs AAKK4 // They both have the same significant card value (AAKK) // Take away one to match card indexes // Hand rank binary padded to four bits // Append card value binary padded to four bits, to binary string // The hand has already been normalised to left most significant cards // Add card binary to actual hand value // If Card is significant for Hand_TYPE then add Card value binary // Else it's a kicker, append 0000 instead // Convert 24 bit binary to an integer