Mercurial > hg > batmud > misc
annotate materials/info.php @ 316:fedf17494a35 misc
Various cleanups.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Wed, 30 Dec 2015 06:58:48 +0200 |
parents | 7615bf7f980f |
children | 1f3fd2d0831b |
rev | line source |
---|---|
250 | 1 <? |
316 | 2 require "mgeneric.inc.php"; |
3 require "materials.inc.php"; | |
4 require "alloys.inc.php"; | |
5 | |
250 | 6 $pageTitle = "Pupunen BatMUD Alloy Browser"; |
7 $pageIndex = "info.php"; | |
316 | 8 |
296
8724b9de70bf
Variable renames, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
292
diff
changeset
|
9 |
316 | 10 $contributors = |
11 [ | |
12 "Hair", "Malacoda", "Kiomet", "Aegenor", "Gileon", "Corto", | |
313 | 13 ]; |
296
8724b9de70bf
Variable renames, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
292
diff
changeset
|
14 |
250 | 15 |
316 | 16 $matTypeTable = |
17 [ | |
18 0 => ["Organic + cloth (sewing)" , 0, 1], | |
19 1 => ["Wood + bone (carpentry)" , 5, 3], | |
20 2 => ["Metal + alloy (blacksmithing)" , 4, 7], | |
21 3 => ["Stone (masonry)" , 6, -1], | |
22 4 => ["Gem (gemcutting)" , 10, -1], | |
23 5 => ["Inorganic (sculpture)" , 8, -1], | |
24 6 => ["Glass (glassblowing)" , 9, -1], | |
25 | |
26 7 => ["Organic" , 0, -1], | |
27 8 => ["Wood" , 5, -1], | |
28 9 => ["Metal" , 4, -1], | |
29 | |
30 10 => ["Cloth" , -1, 1], | |
31 11 => ["Bone" , -1, 3], | |
32 12 => ["Alloy" , -1, 7], | |
33 ]; | |
34 | |
35 | |
36 $matReliability = | |
37 [ | |
38 [ 1, 1, "1 test", "background: #a00; color: white;" ], | |
39 [ 2, 3, "2-3 tests", "background: #750; color: white;" ], | |
40 [ 4, 6, "4-6 tests", "background: #c90; color: black;", "color: black;" ], | |
41 [ 7, 9, "7-10 tests", "background: #080; color: white;" ], | |
42 [ 10, 9999, "10 or more", "background: #0c0; color: black;", "color: black;" ], | |
43 ]; | |
250 | 44 |
45 | |
296
8724b9de70bf
Variable renames, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
292
diff
changeset
|
46 function stGetMatLink($mat, $title = "", $extra = "") |
250 | 47 { |
48 $tmp = ($title != "") ? " title=\"".chentities($title)."\"" : ""; | |
253
1eca10751695
Improve alloy browser output.
Matti Hamalainen <ccr@tnsp.org>
parents:
250
diff
changeset
|
49 return "<a href=\"/mat/".urlencode($mat)."\"".$tmp.">".chentities($mat)."</a>".$extra; |
250 | 50 } |
51 | |
52 | |
316 | 53 function stGetReliabilityStyle($n) |
250 | 54 { |
316 | 55 global $matReliability; |
56 foreach ($matReliability as $chk) | |
313 | 57 { |
58 if ($n >= $chk[0] && $n <= $chk[1]) | |
59 return " class=\"hits".$chk[0]."to".$chk[1]."\""; | |
60 } | |
61 return ""; | |
250 | 62 } |
63 | |
64 | |
296
8724b9de70bf
Variable renames, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
292
diff
changeset
|
65 // |
8724b9de70bf
Variable renames, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
292
diff
changeset
|
66 // Actual main code begins |
8724b9de70bf
Variable renames, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
292
diff
changeset
|
67 // |
8724b9de70bf
Variable renames, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
292
diff
changeset
|
68 $setShowOnly = intval(stGetRequestItem("o", 0, TRUE)); |
8724b9de70bf
Variable renames, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
292
diff
changeset
|
69 |
8724b9de70bf
Variable renames, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
292
diff
changeset
|
70 if (isset($_GET["m"])) |
8724b9de70bf
Variable renames, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
292
diff
changeset
|
71 { |
8724b9de70bf
Variable renames, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
292
diff
changeset
|
72 $setShowMat = strtolower($_GET["m"]); |
8724b9de70bf
Variable renames, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
292
diff
changeset
|
73 $setShowMatName = strtoupper(substr($setShowMat,0,1)).substr($setShowMat, 1); |
8724b9de70bf
Variable renames, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
292
diff
changeset
|
74 } |
8724b9de70bf
Variable renames, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
292
diff
changeset
|
75 |
8724b9de70bf
Variable renames, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
292
diff
changeset
|
76 $setSwapRows = (isset($_GET["swap"]) && is_array($_GET["swap"])) ? $_GET["swap"] : array(); |
8724b9de70bf
Variable renames, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
292
diff
changeset
|
77 |
313 | 78 $extraCSS = []; |
79 $extraInfo = []; | |
316 | 80 foreach ($matReliability as $chk) |
313 | 81 { |
82 $tmps = "hits".$chk[0]."to".$chk[1]; | |
83 $extraCSS[] = " td.".$tmps.", .".$tmps." { ".$chk[3]." }"; | |
84 if (isset($chk[4])) | |
85 $extraCSS[] = " td.".$tmps." a { ".$chk[4]." }"; | |
86 | |
87 $extraInfo[] = "<span class=\"hits".$chk[0]."to".$chk[1]."\"><b>".$chk[2]."</b></span>"; | |
88 } | |
296
8724b9de70bf
Variable renames, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
292
diff
changeset
|
89 |
250 | 90 cmPrintPageHeader($pageTitle, " |
91 <meta name=\"robots\" content=\"nofollow\" /> | |
92 <style type=\"text/css\"> | |
93 span.alternate { color: red; font-weight: bold; } | |
313 | 94 ".implode("\n", $extraCSS)." |
250 | 95 td.nohits, .nohits { background: black; } |
96 td.impossible { background: black; color: #f00; text-align: center; } | |
97 </style> | |
98 "); | |
310 | 99 |
313 | 100 echo |
101 "<h1>".$pageTitle."</h1>\n". | |
102 "<form action=\"".$pageIndex."\" method=\"get\">\n". | |
103 "<table class=\"optionsTable\" width=\"100%\">\n". | |
104 " <tr>\n". | |
105 " <th width=\"25%\">Show type</th>\n". | |
106 " <td rowspan=\"3\" class=\"infobox\">\n". | |
107 " [<a href=\"".$pageIndex."\">Reset/Clear</a>] [<a href=\"index.php\">Material browser</a>]\n". | |
108 " <br />\n". | |
109 " <ul>\n". | |
110 " <li><b>Also available in <a href=\"alloys.txt\">ASCII plaintext format</a>.</b></li>\n". | |
111 " <li><b><a href=\"instructions.php\">Read this</a> for instructions on how you can collect and submit your own alloy research data.</b></li>\n". | |
112 " <li>Only 2-material alloys are supported by this browser.</li>\n". | |
113 " <li>There may be errors, and lots of combinations are not researched yet.</li>\n". | |
314 | 114 " <li>The cell colour reflects how \"reliable\" the information is: ".implode(", ", $extraInfo).".</li>\n"; |
313 | 115 |
316 | 116 if (isset($contributors) && count($contributors) > 0) |
296
8724b9de70bf
Variable renames, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
292
diff
changeset
|
117 { |
313 | 118 $tmp = []; |
316 | 119 foreach ($contributors as $key) |
296
8724b9de70bf
Variable renames, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
292
diff
changeset
|
120 $tmp[] = "<b>".$key."</b>"; |
313 | 121 echo " <li>Thanks to the following people for providing alloying data: ".join(", ", $tmp).".</li>\n"; |
296
8724b9de70bf
Variable renames, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
292
diff
changeset
|
122 } |
310 | 123 |
124 echo | |
314 | 125 " </ul>\n". |
310 | 126 " </td>\n". |
127 " </tr>\n". | |
128 " <tr>\n". | |
129 " <td class=\"icenter\">\n". | |
130 " <select name=\"o\">\n"; | |
131 | |
296
8724b9de70bf
Variable renames, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
292
diff
changeset
|
132 foreach ($matTypeTable as $key => $value) |
250 | 133 { |
255 | 134 $n = 0; |
296
8724b9de70bf
Variable renames, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
292
diff
changeset
|
135 foreach ($matDataTable as $name => $data) |
255 | 136 { |
137 if ($data[14] == $value[1] || $data[14] == $value[2]) | |
138 $n++; | |
139 } | |
140 | |
296
8724b9de70bf
Variable renames, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
292
diff
changeset
|
141 $matTypeTable[$key][] = $n; |
255 | 142 |
143 printf( | |
144 " <option value=\"%s\"%s>%-30s [%d]</option>\n", | |
145 $key, | |
296
8724b9de70bf
Variable renames, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
292
diff
changeset
|
146 ($setShowOnly == $key ? " selected=\"selected\"" : ""), |
255 | 147 chentities($value[0]), $n); |
250 | 148 } |
149 | |
310 | 150 echo |
151 " </select>\n". | |
152 " </td>\n". | |
153 " </tr>\n". | |
154 " <tr>\n". | |
155 " <td class=\"icenter\"><input type=\"submit\" value=\" Filter \" class=\"isubmit\" /></td>\n". | |
156 " </tr>\n". | |
157 "</table>\n". | |
158 "</form>\n"; | |
159 | |
296
8724b9de70bf
Variable renames, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
292
diff
changeset
|
160 if (isset($setShowMat)) |
250 | 161 { |
296
8724b9de70bf
Variable renames, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
292
diff
changeset
|
162 if (!isset($matDataTable[$setShowMat])) |
250 | 163 { |
164 echo | |
296
8724b9de70bf
Variable renames, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
292
diff
changeset
|
165 "<h2>Error! No such material '".$setShowMatName."'</h2>\n". |
250 | 166 "<p>Material is not known. Check spelling.</p>\n"; |
167 } | |
168 else | |
169 { | |
296
8724b9de70bf
Variable renames, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
292
diff
changeset
|
170 echo "<h2>".$setShowMatName."</h2>\n". |
250 | 171 "<table width=\"95%\">\n". |
172 "<tr>"; | |
173 | |
174 $n = 0; | |
296
8724b9de70bf
Variable renames, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
292
diff
changeset
|
175 foreach ($matDataTable[$setShowMat] as $key => $val) |
250 | 176 { |
296
8724b9de70bf
Variable renames, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
292
diff
changeset
|
177 echo "<th>".chentities($matTransNames[$key + 1])."</th><td>"; |
250 | 178 if (is_array($val)) |
179 { | |
313 | 180 $tmp = []; |
296
8724b9de70bf
Variable renames, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
292
diff
changeset
|
181 foreach ($val as $lode) |
8724b9de70bf
Variable renames, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
292
diff
changeset
|
182 $tmp[] = chentities($matTransTable[$key][$lode]); |
8724b9de70bf
Variable renames, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
292
diff
changeset
|
183 echo join(", ", $tmp); |
250 | 184 } |
185 else | |
186 { | |
296
8724b9de70bf
Variable renames, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
292
diff
changeset
|
187 echo chentities($matTransTable[$key][$val]); |
250 | 188 } |
189 echo "</td>"; | |
190 if ($n++ >= 2) { echo "</tr>\n<tr>"; $n = 0; } | |
191 } | |
192 echo "</tr>\n</table>\n"; | |
193 | |
194 echo "<h3>Alloy combinations</h3>\n"; | |
296
8724b9de70bf
Variable renames, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
292
diff
changeset
|
195 if (isset($alloyRevTable[$setShowMat])) |
250 | 196 { |
197 echo "<ul>\n"; | |
296
8724b9de70bf
Variable renames, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
292
diff
changeset
|
198 foreach ($alloyRevTable[$setShowMat] as $mat => $value) |
250 | 199 { |
313 | 200 $tmp = []; |
296
8724b9de70bf
Variable renames, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
292
diff
changeset
|
201 foreach ($value as $qkey => $qval) |
8724b9de70bf
Variable renames, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
292
diff
changeset
|
202 $tmp[] = stGetMatLink($qkey); |
250 | 203 |
296
8724b9de70bf
Variable renames, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
292
diff
changeset
|
204 echo |
8724b9de70bf
Variable renames, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
292
diff
changeset
|
205 " <li>".stGetMatLink($mat)." <b>+</b> ".join(" <b>|</b> ", $tmp). |
8724b9de70bf
Variable renames, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
292
diff
changeset
|
206 "<b> = ".chentities($setShowMat)."</b></li>\n"; |
250 | 207 } |
291 | 208 echo |
209 "</ul>\n". | |
210 "<pre>\n". | |
211 "Syntax: <b>+</b> is AND, <b>|</b> is OR, e.g.:\n". | |
212 "<b>A + B = C</b> means A alloyed with B produces C.\n". | |
213 "<b>A + B | C = D</b> means A alloyed with B <b>or</b> C produces D.\n". | |
214 "</pre>\n"; | |
250 | 215 } |
216 else | |
217 { | |
218 echo "<p>No known alloy combinations.</p>\n"; | |
219 } | |
220 | |
221 /* | |
313 | 222 $typeMats = []; |
309 | 223 foreach ($matDataTable as $name => $data) |
224 { | |
296
8724b9de70bf
Variable renames, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
292
diff
changeset
|
225 if ($data[14] == $matDataTable[$setShowMat][14] && $name != $setShowMat) |
250 | 226 $typeMats[] = $name; |
227 } | |
228 | |
309 | 229 echo "<p>Full mix: "; |
250 | 230 if (list($a, $b) = each($typeMats)) |
296
8724b9de70bf
Variable renames, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
292
diff
changeset
|
231 echo stGetMatLink($b); |
250 | 232 |
233 while (list($a, $b) = each($typeMats)) | |
296
8724b9de70bf
Variable renames, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
292
diff
changeset
|
234 echo " <b>+</b> ".stGetMatLink($b); |
309 | 235 echo "</p>\n"; |
250 | 236 */ |
237 | |
238 echo "<h3>Mixtable</h3>\n"; | |
296
8724b9de70bf
Variable renames, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
292
diff
changeset
|
239 if (count($alloyTable[$setShowMat]) > 0) |
250 | 240 { |
241 echo | |
309 | 242 "<table class=\"matTable\">". |
243 " <tr>\n". | |
244 " <th>+</th>\n"; | |
245 | |
296
8724b9de70bf
Variable renames, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
292
diff
changeset
|
246 foreach ($alloyTable[$setShowMat] as $key => $value) |
250 | 247 { |
296
8724b9de70bf
Variable renames, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
292
diff
changeset
|
248 echo "<th>".stGetMatLink($key)."</th>\n"; |
250 | 249 } |
309 | 250 |
251 echo | |
252 " </tr>\n". | |
253 " <tr><th>".chentities($setShowMat)."</th>"; | |
254 | |
296
8724b9de70bf
Variable renames, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
292
diff
changeset
|
255 foreach ($alloyTable[$setShowMat] as $key => $value) |
250 | 256 { |
309 | 257 if (list($a, $b) = each($value)) |
258 { | |
316 | 259 echo "<td ".stGetReliabilityStyle($b).">".stGetMatLink($a)."</td>"; |
309 | 260 } |
250 | 261 } |
262 echo "</tr></table>\n"; | |
263 } | |
264 else | |
265 { | |
266 echo "<p>No mixtable entries.</p>\n"; | |
267 } | |
268 } | |
269 } | |
270 else | |
271 { | |
272 /* | |
273 * Print alloy table for given material type | |
274 */ | |
275 // Filter table from maintable matching desired material type(s) | |
313 | 276 $currTable = []; |
296
8724b9de70bf
Variable renames, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
292
diff
changeset
|
277 foreach ($matDataTable as $name => $data) |
250 | 278 { |
296
8724b9de70bf
Variable renames, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
292
diff
changeset
|
279 if ($data[14] == $matTypeTable[$setShowOnly][1] || |
8724b9de70bf
Variable renames, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
292
diff
changeset
|
280 $data[14] == $matTypeTable[$setShowOnly][2]) |
250 | 281 $currTable[] = $name; |
282 } | |
283 | |
284 // Swap desired rows | |
296
8724b9de70bf
Variable renames, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
292
diff
changeset
|
285 if (count($setSwapRows) > 0) |
250 | 286 { |
313 | 287 $str = []; |
250 | 288 $nkeys = count($currTable); |
296
8724b9de70bf
Variable renames, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
292
diff
changeset
|
289 foreach ($setSwapRows as $from => $to) |
250 | 290 if ($from >= 0 && $from < $nkeys && $to >= 0 && $to < $nkeys && $to != $from) |
291 { | |
292 $str[] = $from." <=> ".$to; | |
293 | |
294 $tmp = $currTable[$from]; | |
295 $currTable[$from] = $currTable[$to]; | |
296 $currTable[$to] = $tmp; | |
297 } | |
309 | 298 |
250 | 299 if (count($str) > 0) |
307
d6b1b38cbb30
Improve statistics calculation.
Matti Hamalainen <ccr@tnsp.org>
parents:
302
diff
changeset
|
300 { |
250 | 301 echo "<p>Swapped rows: ".implode(", ", $str)."</p>\n"; |
307
d6b1b38cbb30
Improve statistics calculation.
Matti Hamalainen <ccr@tnsp.org>
parents:
302
diff
changeset
|
302 } |
250 | 303 } |
304 | |
305 | |
306 // Print out the table | |
307 echo | |
308 "<table class=\"alloyTable\">". | |
309 " <tr>\n". | |
310 " <th>-</th>\n"; | |
311 | |
312 foreach ($currTable as $name) | |
313 { | |
296
8724b9de70bf
Variable renames, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
292
diff
changeset
|
314 echo " <th>".stGetMatLink($name)."</th>\n"; |
250 | 315 } |
316 echo " </tr>\n"; | |
317 | |
255 | 318 $researched = 0; |
319 $researchValue = 0; | |
307
d6b1b38cbb30
Improve statistics calculation.
Matti Hamalainen <ccr@tnsp.org>
parents:
302
diff
changeset
|
320 $total = 0; |
255 | 321 |
250 | 322 foreach ($currTable as $mat1) |
323 { | |
296
8724b9de70bf
Variable renames, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
292
diff
changeset
|
324 echo " <tr><th>".stGetMatLink($mat1)."</th>"; |
250 | 325 foreach ($currTable as $mat2) |
326 { | |
327 // Is the combo possible? | |
328 if ($mat1 != $mat2) | |
329 { | |
330 // Check for combination result | |
331 if (isset($alloyTable[$mat1][$mat2])) | |
332 $tmp = $alloyTable[$mat1][$mat2]; | |
333 else | |
334 if (isset($alloyTable[$mat2][$mat1])) | |
335 $tmp = $alloyTable[$mat2][$mat1]; | |
336 else | |
337 unset($tmp); | |
338 | |
339 if (isset($tmp)) | |
340 { | |
341 arsort($tmp); | |
342 $value = 0; | |
343 foreach ($tmp as $a => $b) | |
344 $value += $b; | |
345 | |
255 | 346 $researched++; |
347 $researchValue += $value; | |
348 | |
313 | 349 $slist = []; |
250 | 350 foreach ($tmp as $a => $b) |
351 { | |
296
8724b9de70bf
Variable renames, cleanups, etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
292
diff
changeset
|
352 $slist[] = stGetMatLink($a, |
250 | 353 $b." successful alloys (".$mat1." + ".$mat2." = ".$a.")". |
255 | 354 (count($tmp) > 1 ? " [UNSTABLE]" : "") |
355 ); | |
356 // , " <sup>".$b."</sup>"); | |
250 | 357 } |
358 echo | |
316 | 359 "<td".stGetReliabilityStyle($value, count($tmp) > 1 ? " mitalic" : "").">". |
250 | 360 join(" <span class=\"alternate\">/</span> ", $slist)."</td>"; |
361 } | |
362 else | |
363 echo "<td class=\"nohits\" title=\"Not researched\">?</td>"; | |
309 | 364 |
307
d6b1b38cbb30
Improve statistics calculation.
Matti Hamalainen <ccr@tnsp.org>
parents:
302
diff
changeset
|
365 $total++; |
250 | 366 } |
367 else | |
368 { | |
369 echo "<td class=\"impossible\" title=\"Impossible combination\">-</td>"; | |
370 } | |
371 } | |
372 echo "</tr>\n"; | |
373 } | |
255 | 374 |
307
d6b1b38cbb30
Improve statistics calculation.
Matti Hamalainen <ccr@tnsp.org>
parents:
302
diff
changeset
|
375 // |
d6b1b38cbb30
Improve statistics calculation.
Matti Hamalainen <ccr@tnsp.org>
parents:
302
diff
changeset
|
376 // Calculate some statistics |
d6b1b38cbb30
Improve statistics calculation.
Matti Hamalainen <ccr@tnsp.org>
parents:
302
diff
changeset
|
377 // |
309 | 378 $researchValue /= $researched * 15.0; |
379 if ($researchValue > 1.0) | |
380 $researchValue = 1.0; | |
381 | |
307
d6b1b38cbb30
Improve statistics calculation.
Matti Hamalainen <ccr@tnsp.org>
parents:
302
diff
changeset
|
382 $total /= 2; |
d6b1b38cbb30
Improve statistics calculation.
Matti Hamalainen <ccr@tnsp.org>
parents:
302
diff
changeset
|
383 $researched /= 2; |
255 | 384 |
307
d6b1b38cbb30
Improve statistics calculation.
Matti Hamalainen <ccr@tnsp.org>
parents:
302
diff
changeset
|
385 printf( |
d6b1b38cbb30
Improve statistics calculation.
Matti Hamalainen <ccr@tnsp.org>
parents:
302
diff
changeset
|
386 "</table>\n". |
255 | 387 "<div><b>%1.2f%%</b> (%d / %d) of combinations researched. ". |
388 "Estimating <b>%1.2f%%</b> overall accuracy.</div>\n", | |
389 ($researched * 100.0) / $total, $researched, $total, | |
307
d6b1b38cbb30
Improve statistics calculation.
Matti Hamalainen <ccr@tnsp.org>
parents:
302
diff
changeset
|
390 $researchValue * 100.0); |
250 | 391 } |
392 | |
393 cmPrintPageFooter(); | |
394 ?> |