here's what I've got so far, (only shuffles, then deals the cards (i'm aware it's from the bottom of the stack, but it really doesn't matter if they all come from the same spot.)
I'm also aware that holding the suit names in the array isn't the best way to go about things, but I havn't been able to figure out any other way to determien which suit is being called after the cards have been shuffled.
Basically, I'm looking for something that will help me compare the two hands, based on the standard rules of poker.
I've thought about writing a probability algorithm to determine which has the lowest probability (best hand) and then using a function to determine which hand is better based on the numerical value of the sum of the cards in case there is a tie in probability.
Has anyone tackled this problem before?
function DoShuffle(&$array)
{
for ($i = count($array); --$i; $i > 0)
{
$j = @mt_rand(0, $i+1);
$temp = $array[$i];
$array[$i] = $array[$j];
$array[$j] = $temp;
}
}
$clubs = array("d2", "d3", "d4", "d5", "d6", "d7", "d8", "d9", "d10", "dj", "dq", "dk", "da");
$clubs = array("h2", "h3", "h4", "h5", "h6", "h7", "h8", "h9", "h10", "hj", "hq", "hk", "ha");
$clubs = array("s2", "s3", "s4", "s5", "s6", "s7", "s8", "s9", "s10", "sj", "sq", "sk", "sa");
$clubs = array("c2", "c3", "c4", "c5", "c6", "c7", "c8", "c9", "c10", "cj", "cq", "ck", "ca");
$deck = array_merge($clubs,$clubs,$clubs,$clubs);
DoShuffle($deck);
DoShuffle($deck);
DoShuffle($deck);
DoShuffle($deck);
DoShuffle($deck);
DoShuffle($deck);
$player_hand = array();
$dealer_hand = array();
$card_count=1;
while ($card_count <= 5)
{
$num = count($deck);
array_push($player_hand,$deck[($num-1)]);
array_pop($deck);
$num = count($deck);
array_push($dealer_hand,$deck[($num-1)]);
array_pop($deck);
$card_count++;
}
print "player<br>";
natsort($player_hand);
natsort($dealer_hand);
foreach ($player_hand as $player_card)
{
print $player_card." - ";
}
print "<br><br>";
print "dealer<br>";
foreach ($dealer_hand as $dealer_card)
{
print $dealer_card." - ";
}