Aaron Dale, Web Developer

Projects - Feedback - Code

Poker Game Logic

This is one of the functions used in Lone Wolf Poker to evaluate the hands of the players.

The accumulation of code to process and evaluate and compare all hands for a 10 player game takes less than 0.02 seconds on a computer with a CPU passmark score of 12,500.

Aaron rewrote this code about four times with the intention of reducing the CPU load time as much as possible and discovered that this was the best he could achieve within PHP. The way PHP handles lists isn't ideal and it was interesting to find this limitation.
function is_straight_flush($seven_cards){ $dominant_suit = dominant_suit($seven_cards); if($dominant_suit == "NONE"){ //no straight flush return is_four_of_a_kind($seven_cards); } $suited_cards = []; foreach($seven_cards as $card){ $face = substr($card, 0, 1); $suit = substr($card, 1, 1); $value = substr($card, 2, 2); if($suit == $dominant_suit){ $suited_cards[] = $card; } } $straight = eval_straight($suited_cards); if($straight != "NONE"){ $result['HAND_NAME'] = 'straight flush'; $result['HAND'] = $straight; return $result; } //no straight flush return is_four_of_a_kind($seven_cards); }

Portfolio - Feedback - Code