@ 2025-07-06T04:26:16Z }
<?php
//Case Battle Fairness | Round Validation
$serverSeed = 'cef7544d66f612a41121f506a2903135'; // Server seed
$eosBlockSeed = '1a869e974688d612eae6886a5813c2d67da069f3be2b3bf23d381cf2705c9dab'; // EOS Block Seed
// Update this to true if you are validating a tiebreaker result.
$isTiebreaker = false;
/*
* Case Ticket's Quantity, by default it's 100,000
* We only change this if there's a case that has different ticket distribution.
* Right now, all cases use 100,000 by default.
* IMPORTANT: If it's the tiebreaker round, this will be number of players participating on the tiebreaker.
* For example, if two players are participating on a tiebreaker the ticketQuantity is 2.
*/
$ticketQuantity = 100000;
/* ------------------ */
if ($serverSeed == '' || $eosBlockSeed == '') {
echo "Fill in details";
return;
}
define('MAX_HEX_SEGMENTS', 6);
define('HEX_SEGMENT_SIZE', 2);
define('BASE_FOR_HEX_CONVERSION', 256);
define('HASH_TYPE', 'sha256');
if (!function_exists('calculateDecimalValue')) {
function calculateDecimalValue(string $preResult): float
{
$decimalValue = 0;
for ($i = 0; $i < MAX_HEX_SEGMENTS; $i++) {
$hexValue = substr($preResult, HEX_SEGMENT_SIZE * $i, HEX_SEGMENT_SIZE);
$decimalValue += hexdec($hexValue) / pow(BASE_FOR_HEX_CONVERSION, $i + 1);
}
return $decimalValue;
}
}
if (!function_exists('getProvablyFairResult')) {
function getProvablyFairResult(string $init, string $serverSeed, int $qty): array
{
$preResult = hash_hmac(HASH_TYPE, $init, $serverSeed);
$decimalValue = calculateDecimalValue($preResult);
$result = (int) ($decimalValue * $qty) + 1;
return [
'preResult' => $preResult,
'result' => $result,
];
}
}
$serverSeed = preg_replace("/\r|\n/", "", $serverSeed);
$eosBlockSeed = preg_replace("/\r|\n/", "", $eosBlockSeed);
// Print header
echo "Case Battle Fairness Validation Results\n";
echo "=====================================\n";
echo "Server Seed: " . substr($serverSeed, 0, 16) . "...\n";
echo "EOS Block Seed: " . substr($eosBlockSeed, 0, 32) . "...\n";
echo "Ticket Quantity: " . number_format($ticketQuantity) . "\n\n";
// Create table header
echo str_pad("Round", 7) . " | ";
for ($player = 1; $player <= 4; $player++) {
echo str_pad("Player $player", 12) . " | ";
}
echo "\n";
echo str_repeat("-", 7) . " | " . str_repeat(str_repeat("-", 12) . " | ", 4) . "\n";
// Calculate and display results for all rounds and players
for ($roundNumber = 1; $roundNumber <= 50; $roundNumber++) {
echo str_pad($roundNumber, 7, " ", STR_PAD_LEFT) . " | ";
for ($playerPosition = 1; $playerPosition <= 4; $playerPosition++) {
if ($isTiebreaker) {
$stringToHash = "$eosBlockSeed-$roundNumber";
} else {
$stringToHash = "$eosBlockSeed-$roundNumber-$playerPosition";
}
$result = getProvablyFairResult($stringToHash, $serverSeed, $ticketQuantity);
echo str_pad(number_format($result['result']), 12, " ", STR_PAD_LEFT) . " | ";
}
echo "\n";
// Add a separator line every 10 rounds for better readability
if ($roundNumber % 10 == 0 && $roundNumber < 50) {
echo str_repeat("-", 7) . " | " . str_repeat(str_repeat("-", 12) . " | ", 4) . "\n";
}
}
echo "\n\nNote: Each result represents the ticket number (1 to " . number_format($ticketQuantity) . ") that won for that player in that round.\n";
// Optional: Show example of hash calculation for verification
echo "\n\nExample Verification (Round 1, Player 1):\n";
echo "==========================================\n";
$exampleString = "$eosBlockSeed-1-1";
$exampleResult = getProvablyFairResult($exampleString, $serverSeed, $ticketQuantity);
echo "Input String: " . substr($exampleString, 0, 50) . "...\n";
echo "HMAC-SHA256 Hash: " . $exampleResult['preResult'] . "\n";
echo "Result: " . number_format($exampleResult['result']) . "\n";
?>
Enable javascript to submit You have javascript disabled. You will not be able to edit any code.
Here you find the average performance (time & memory) of each version. A grayed out version indicates it didn't complete successfully (based on exit-code).
Version System time (s) User time (s) Memory (MiB) 8.4.12 0.004 0.005 24.04 8.4.11 0.004 0.007 18.95 8.4.10 0.013 0.011 18.79 8.4.9 0.021 0.009 20.74 8.4.8 0.015 0.007 17.94 8.4.7 0.027 0.003 17.66 8.4.6 0.017 0.009 18.17 8.4.5 0.017 0.006 17.57 8.4.4 0.021 0.003 17.80 8.4.3 0.020 0.005 17.88 8.4.2 0.020 0.005 17.67 8.4.1 0.019 0.005 17.77 8.3.25 0.007 0.004 17.44 8.3.24 0.012 0.010 17.29 8.3.23 0.018 0.004 16.89 8.3.22 0.017 0.005 17.06 8.3.21 0.017 0.005 16.80 8.3.20 0.014 0.007 17.18 8.3.19 0.020 0.007 16.79 8.3.18 0.044 0.006 16.72 8.3.17 0.040 0.010 16.76 8.3.16 0.037 0.005 16.92 8.3.15 0.021 0.004 16.93 8.3.14 0.018 0.005 16.97 8.3.13 0.018 0.003 16.99 8.3.12 0.022 0.008 16.98 8.3.11 0.034 0.011 16.64 8.3.10 0.029 0.007 17.01 8.3.9 0.045 0.010 16.66 8.3.8 0.026 0.006 17.00 8.3.7 0.036 0.006 16.85 8.3.6 0.024 0.003 16.47 8.3.5 0.035 0.009 17.00 8.3.4 0.035 0.010 18.10 8.3.3 0.028 0.010 17.87 8.3.2 0.032 0.008 17.70 8.3.1 0.031 0.006 17.75 8.3.0 0.023 0.006 17.67 8.2.29 0.026 0.012 16.89 8.2.28 0.032 0.008 17.02 8.2.27 0.035 0.009 16.84 8.2.26 0.027 0.003 16.58 8.2.25 0.018 0.004 16.79 8.2.24 0.018 0.006 16.52 8.2.23 0.019 0.003 16.54 8.2.22 0.035 0.011 16.73 8.2.21 0.031 0.012 16.30 8.2.20 0.037 0.011 16.76 8.2.19 0.040 0.006 16.51 8.2.18 0.034 0.009 16.86 8.2.17 0.029 0.009 17.98 8.2.16 0.033 0.010 18.07 8.2.15 0.026 0.006 17.84 8.2.14 0.039 0.009 17.87 8.2.13 0.028 0.006 17.85 8.2.12 0.033 0.012 17.91 8.2.11 0.014 0.007 18.05 8.2.10 0.030 0.011 17.74 8.2.9 0.036 0.005 17.79 8.2.8 0.015 0.006 17.68 8.2.7 0.026 0.008 17.75 8.2.6 0.034 0.012 17.94 8.2.5 0.038 0.006 17.75 8.2.4 0.035 0.010 17.71 8.2.3 0.028 0.010 17.53 8.2.2 0.013 0.006 17.64 8.2.1 0.013 0.008 17.66 8.2.0 0.017 0.003 17.73
preferences:dark mode live preview ace vim emacs key bindings
28.82 ms | 403 KiB | 5 Q