/
131b.php
123 lines (98 loc) · 2.82 KB
/
131b.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
<?php
require_once('inc.cls.cardgame.php');
Card::$__tostring = function ($c) {
return '<img src="images/' . $c->suit . '.gif" /> ' . strtoupper($c->short);
};
$objDeck = new Deck();
$objDeck->shuffle();
$iPlayers = 12;
define('LOWEST_WORTHY_HAND', (int) @$_GET['min'] ?: 6);
$arrPublic = $arrPlayers = array();
for ( $i=0; $i<$iPlayers; $i++ ) {
$arrPlayers[$i] = array();
array_push($arrPlayers[$i], $objDeck->next());
array_push($arrPlayers[$i], $objDeck->next());
}
while ( 5 > count($arrPublic) ) {
array_push($arrPublic, $objDeck->next());
}
$fUtcStart = microtime(true);
/* test *
$arrPublic = array(
new Card(8),
new Card(0),
new Card(3),
new Card(7),
new Card(6),
);
$arrPlayers[0] = array(
new Card(5),
new Card(4),
);
/* test */
require_once('inc.cls.pokertexasholdem.php');
$bNothingWorthy = true;
$fMaxHand = 0;
$arrHands = array();
foreach ( $arrPlayers AS $k => $arrPlayer ) {
$fHand = PokerTexasHoldem::score(array_merge($arrPublic, $arrPlayer));
$arrHands[$k] = $fHand;
if ( (float) $fHand > $fMaxHand ) {
$fMaxHand = (float) $fHand;
}
if ( (float) LOWEST_WORTHY_HAND <= (float) $fHand ) {
$bNothingWorthy = false;
}
}
if ( !empty($_GET['plain']) ) {
if ( $bNothingWorthy ) {
echo '<meta http-equiv="refresh" content="0" />';
}
echo '<title>' . $fMaxHand . '</title>';
echo '<pre>' . $fMaxHand . '</pre>';
echo '<pre>' . number_format(microtime(1) - $fUtcStart, 4) . '</pre>';
exit;
}
?>
<html>
<head>
<style type="text/css">
body, table {
background-color: #444;
font-family : verdana, arial;
font-size : 10px;
color : white;
}
</style>
</head>
<body>
<?php
echo '<table border="0" cellpadding="2" cellspacing="1">';
foreach ( $arrPlayers AS $k => $arrPlayer ) {
echo '<tr>';
if ( 0 == $k ) {
echo '<td rowspan="'.count($arrPlayers).'">'.implode(', ', $arrPublic).'</td>';
echo '<td rowspan="'.count($arrPlayers).'"> + </td>';
}
$fHand = $arrHands[$k];
$szHand = $fHand;
if ( (float) LOWEST_WORTHY_HAND <= (float) $fHand ) {
$szHand = '<b class="worthy h' . str_replace('.', '_', (float) $fHand) . '">' . $szHand . '</b>';
}
echo '<td>'.implode(', ', $arrPlayer).'</td>';
echo '<td> = </td>';
echo '<td>'.$szHand.'</td>';
echo '<td> = </td>';
echo '<td>'.PokerTexasHoldem::readable_hand($fHand).'</td></tr>';
}
echo '<tr><td colspan="7" align="center"><b'.( $bNothingWorthy ? '' : ' style="color:yellow;"' ).'>Winner</b>: '.PokerTexasHoldem::readable_hand($m=max($arrHands)).' ('.$m.')</td></tr>';
echo '</table>';
?><style type="text/css">.worthy{color:red;}table tr td b.h<?php echo str_replace('.', '_', (float)$m); ?>{color:yellow;}</style><?php
if ( $bNothingWorthy ) {
echo '<meta http-equiv="refresh" content="0" />';
}
echo '<p>'.number_format(($fTime=microtime(true)-$fUtcStart), 4).'</p>';
?>
</body>
<title><?php echo $fMaxHand; ?></title>
</html>