Nakowa would have lost FAR more today had the max bet remained 1%. How is this unfair?
It was the Bitcointalk forum that inspired us to create Bitcointalksearch.org - Bitcointalk is an excellent site that should be the default page for anybody dealing in cryptocurrency, since it is a virtual gold-mine of data. However, our experience and user feedback led us create our site; Bitcointalk's search is slow, and difficult to get the results you need, because you need to log in first to find anything useful - furthermore, there are rate limiters for their search functionality.
The aim of our project is to create a faster website that yields more results and faster without having to create an account and eliminate the need to log in - your personal data, therefore, will never be in jeopardy since we are not asking for any of your data and you don't need to provide them to use our site with all of its capabilities.
We created this website with the sole purpose of users being able to search quickly and efficiently in the field of cryptocurrency so they will have access to the latest and most accurate information and thereby assisting the crypto-community at large.
HMAC-SHA512(K,m) = SHA512((K ⊕ opad) + SHA512((K ⊕ ipad) + m))
function getLuckyNumber($server, $client, $nonce) {
$str = hash_hmac("sha512", "$client:$nonce", $server);
for ($i=0; $i$hex = substr($str, $i, 5);
$dec = hexdec($hex);
if ($dec < 1000000)
return $dec / 10000;
}
}
HMAC-SHA512(K,m) = SHA512( <512 bits> + <512 bits> + <192 bits> + ':' + <32 bits> )
if (!function_exists("stats_standard_deviation")) {
print "need to install stats package\n".
"pecl install stats\n".
"echo extension=stats.so > /etc/php.d/stats.ini\n";
exit;
}
// Source data
// https://just-dice.com/nakowa.txt.bz2
// https://just-dice.com/nakowa2.txt.bz2
$fh = fopen("nakowa.txt","rb");
if (!$fh) {
exit;
}
# remove headers
$line=fgets($fh); $line=fgets($fh); $line=fgets($fh);
# init our counts
$sum = 0;
$gray_bets = array();
resetGrayBets($gray_bets);
// reset sums
function resetGrayBets(&$gray_bets) {
$bits = 12;
// 1 bit
for ($i=0; $i<$bits; $i++)
$gray_bets[1 << $i] = array();
// 2 bits
for ($i=0; $i<$bits; $i++)
for ($j=$i+1; $j<$bits; $j++)
$gray_bets[(1 << $i) | (1 << $j)] = array();
// 3 bits
for ($i=0; $i<$bits; $i++)
for ($j=$i+1; $j<$bits; $j++)
for ($k=$j+1; $k<$bits; $k++)
$gray_bets[(1 << $i) | (1 << $j) | (1 << $k)] = array();
// 4 bits
for ($i=0; $i<$bits; $i++)
for ($j=$i+1; $j<$bits; $j++)
for ($k=$j+1; $k<$bits; $k++)
for ($l=$k+1; $k<$bits; $k++)
$gray_bets[(1 << $i) | (1 << $j) | (1 << $k) | (1 << $l)] = array();
# ksort($gray_bets);
}
// display sums
function dumpGraySums($gray_bets) {
$report = array();
foreach ($gray_bets as $i=>$arr) {
$ibin = substr("00000000000000000". decbin($i), -16);
if (count($arr) == 0)
continue;
$sum = $mean = $stdev = 0;
if (count($arr) != 0) {
$sum = array_sum($arr);
$mean = $sum / count($arr);
$min = min($arr);
$max = max($arr);
$stdev = stats_standard_deviation($arr);
}
$report[] = array(
'i' => $i,
'ibin' => $ibin,
'sum' => $sum,
'count' => count($arr),
'mean' => $mean,
'min' => $min,
'max' => $max,
'stdev' => $stdev,
);
}
usort($report, function($a,$b){
return $b['mean'] - $a['mean'];
# return $b['stdev'] - $a['stdev'];
});
foreach ($report as $i=>$info) {
$info['sum'] = sprintf("%4.3u", $info['sum']);
$info['count'] = sprintf("%4.3u", $info['count']);
$info['min'] = number_format($info['min'], 3);
$info['mean'] = number_format($info['mean'], 3);
$info['max'] = number_format($info['max'], 3);
$info['stdev'] = number_format($info['stdev'], 3);
print " {$info['ibin']}: sum={$info['sum']}, count={$info['count']}, min/mean/max={$info['min']}/{$info['mean']}/{$info['max']}, stdev={$info['stdev']})\n";
}
}
$last_nonce = -1;
while (($line=fgets($fh)) !== false) {
list($uid,$bid,$nonce,$bet,$chance,$profit) = preg_split('/\t/', $line);
// cast to int
$uid = (int)$uid;
$bid = (int)$bid;
$nonce = (int)$nonce;
$bet = (int)$bet;
$change = (int)$change;
$profit = (int)$profit;
if ($last_nonce == -1)
$last_nonce = $nonce;
if ($bet == 0)
continue;
// values in BTC
$bet /= 100000000;
$profit /= 100000000;
$nonce_bin = substr("00000000000000000". decbin($nonce), -16);
# if ($bet >= 10)
print "$uid\t$bid\t$nonce\t$nonce_bin\t{$bet}BTC\t$chance\t{$profit}BTC\n";
$sum += $profit;
foreach ($gray_bets as $code=>$ignore) {
# edit-1 start
if ($nonce < 0x0000100) $nonce_bytes = $nonce << 24;
else if ($nonce < 0x0010000) $nonce_bytes = $nonce << 16;
else if ($nonce < 0x1000000) $nonce_bytes = $nonce << 8;
else $nonce_bytes = $nonce;
if (($nonce_bytes & $code) == $code) {
#edit-1 end
$gray_bets[$code][] = $bet;
}
}
if ($nonce < $last_nonce) {
print "sum = $sum\n";
dumpGraySums($gray_bets);
$sum = 0;
resetGrayBets($gray_bets);
}
$last_nonce = $nonce;
}
dumpGraySums($gray_bets);