Poll

6 votes (54.54%)
No votes (0%)
5 votes (45.45%)
1 vote (9.09%)
No votes (0%)
1 vote (9.09%)
No votes (0%)
No votes (0%)
3 votes (27.27%)
1 vote (9.09%)

11 members have voted

Wizard
Administrator
Wizard 
Joined: Oct 14, 2009
  • Threads: 1343
  • Posts: 22216
Thanks for this post from:
Gialmere
June 10th, 2020 at 11:50:08 AM permalink
I applaud the concept of "provably fair gaming," but for most players it is probably too much of a fuss to confirm a result is fair to bother with, if the player understands how to do it at all.

The purpose of this page will be to provide some PHP scripts to fairly easily confirm a result in various such games, as based on how the outcome it determined at Crypto.Games. Choosing this casino does not imply an endorsement, it was picked fairly randomly.



<?php
// Dice game conversion for Crypto.Games

$client_seed = "dQt2XQ1kMkdgHTN9PGN4CWDHs78kz4fdehgIAgCm";
$server_seed = "Gp99P8R250gQFnd4Lnr2csXC9JtKCHHkzXKoH7DN";
$combined_seed = $server_seed.$client_seed;
echo "Combined seed = $combined_seed\n";
$combined_hash = hash('sha512', $combined_seed);
echo "Hash of combined seed = $combined_hash\n";
$position=0;
$first_five=substr($combined_hash,$position,5);
echo "First five characters, starting with position $position = $first_five\n";
do
{
$hex_to_dec=hexdec($first_five);
$position+=5;
}
while ($hex_to_dec > 999999);
echo "Converted to decimal = $hex_to_dec\n";

$mod5=$hex_to_dec%100000;
echo "\nLast five of these characters = $mod5\n";

// Procedure
// 1. Join server and client seeds, server seed first.
// 2. Generate a SHA-512 hash of the string from step 1.
// 3. Convert first five characters of the hash from hexidecimal to decimal.
// 4. If the result from step 3 is over 999,999 then advance five positions in the hash and go back to step 3. Otherwise, go onto step 5.
// 5. Take the last five digits from step 3. This shall be the game outcome. <?php
// Dice game conversion for Crypto.Games

$client_seed = "dQt2XQ1kMkdgHTN9PGN4CWDHs78kz4fdehgIAgCm";
$server_seed = "Gp99P8R250gQFnd4Lnr2csXC9JtKCHHkzXKoH7DN";
$combined_seed = $server_seed.$client_seed;
echo "Combined seed = $combined_seed\n";
$combined_hash = hash('sha512', $combined_seed);
echo "Hash of combined seed = $combined_hash\n";
$position=0;
$first_five=substr($combined_hash,$position,5);
echo "First five characters, starting with position $position = $first_five\n";
do
{
$hex_to_dec=hexdec($first_five);
$position+=5;
}
while ($hex_to_dec > 999999);
echo "Converted to decimal = $hex_to_dec\n";

$mod5=$hex_to_dec%100000;
echo "\nLast five of these characters = $mod5\n";

// Procedure
// 1. Join server and client seeds, server seed first.
// 2. Generate a SHA-512 hash of the string from step 1.
// 3. Convert first five characters of the hash from hexidecimal to decimal.
// 4. If the result from step 3 is over 999,999 then advance five positions in the hash and go back to step 3. Otherwise, go onto step 5.
// 5. Take the last five digits from step 3. This shall be the game outcome.


1. Click here to run the script.
1. Enter your client seed on line 4.
2. Enter the server seed on line 5.
3. Click "execute code."

The outcome of the bet will be shown on the last line.

After Dice, I will be looking at Minesweeper and Plinko, which will be more involved.

The question for the poll is do you think this would be a worthwhile tool at Wizard of Odds?

For now, let me pause for questions and comments.
Last edited by: Wizard on Jun 15, 2020
It's not whether you win or lose; it's whether or not you had a good bet.
ThatDonGuy
ThatDonGuy
Joined: Jun 22, 2011
  • Threads: 95
  • Posts: 4382
June 10th, 2020 at 1:28:37 PM permalink
Let me see if I understand this:
You start with two seeds - a 40-character (each of which I assume represents a 6-bit number, similar to Base64) seed from the server, and a "client seed" that you supply.
Append your seed to the client seed to get an 80-character string.
Apply a SHA512 hash to it, resulting in a 128-hex-digit "hash string."
Starting from the left, take 5 characters at a time from the hash string, convert those 5 characters to a decimal number, and stop when that number < 1,000,000
Return the last decimal number generated, mod 100,000.

In this case, what is this result supposed to represent? Does the game use a random integer in [0, 99,999] somehow?
Wizard
Administrator
Wizard 
Joined: Oct 14, 2009
  • Threads: 1343
  • Posts: 22216
June 10th, 2020 at 4:04:40 PM permalink
Quote: ThatDonGuy

Let me see if I understand this:
You start with two seeds - a 40-character (each of which I assume represents a 6-bit number, similar to Base64) seed from the server, and a "client seed" that you supply.
Append your seed to the client seed to get an 80-character string.
Apply a SHA512 hash to it, resulting in a 128-hex-digit "hash string."
Starting from the left, take 5 characters at a time from the hash string, convert those 5 characters to a decimal number, and stop when that number < 1,000,000
Return the last decimal number generated, mod 100,000.



Yes, that looks right.

Quote:

In this case, what is this result supposed to represent? Does the game use a random integer in [0, 99,999] somehow?



Yes, it's supposed to be a random number between 0 and 99,999. The player may be on it being above/below any number he chooses. The win is inversely proportional to the probability of winning. To be specific,

w * p = 0.99,

Where w = win (on a for one basis), p = probability of winning.
It's not whether you win or lose; it's whether or not you had a good bet.
Gialmere
Gialmere
Joined: Nov 26, 2018
  • Threads: 38
  • Posts: 1695
June 10th, 2020 at 4:48:08 PM permalink
As you point out, few will be interested in this. Those who are, however, will be very grateful. Some of them will just be looking for a way to test the fairness of a site they intend to play at. On the other hand, most will be filled with anger and suspicion over some gaming site's results and to find a tool like this--freely available complete with detailed explanations of what's going on--will be like thirsty wanderers finding an oasis in the desert (which is sort of the point of WOO).

Who knows? As online gaming spreads maybe the testers will mushroom in numbers. This begs the question: How often would the Wizard recommend randomly testing an online site to be reassured of its honesty?
Have you tried 22 tonight? I said 22.
Wizard
Administrator
Wizard 
Joined: Oct 14, 2009
  • Threads: 1343
  • Posts: 22216
June 11th, 2020 at 4:40:37 PM permalink
Quote: Gialmere

As you point out, few will be interested in this. Those who are, however, will be very grateful. Some of them will just be looking for a way to test the fairness of a site they intend to play at. On the other hand, most will be filled with anger and suspicion over some gaming site's results and to find a tool like this--freely available complete with detailed explanations of what's going on--will be like thirsty wanderers finding an oasis in the desert (which is sort of the point of WOO).



Thank you. I would like to shed more light on the topic, even if my scripts work for just one site.

Quote:

Who knows? As online gaming spreads maybe the testers will mushroom in numbers. This begs the question: How often would the Wizard recommend randomly testing an online site to be reassured of its honesty?



I would recommend clicking "provably fair" or whatever the button is to see the hash of the client seed the next bet. The casino can know if this is getting clicked and I would think would be less likely to cheat if they knew the player was checking the outcome. To take it a step further, press some random keys for the player seed. Checking the actual outcome is kind of a pain, which I am trying to make less painful, but those two easy steps I think will be a huge deterrent to being cheated.
It's not whether you win or lose; it's whether or not you had a good bet.
Wizard
Administrator
Wizard 
Joined: Oct 14, 2009
  • Threads: 1343
  • Posts: 22216
June 11th, 2020 at 9:48:40 PM permalink
Next is my code for the game of Plinko.



<?php
// Plinko game conversion for Crypto.Games

$server_seed = "k34pQFblHvQAJ33zZZHCQtlFlhHb4KTtw2qhOahC";
$client_seed = "6VoqO9MXdSp5xSmiq2L6xcvn2XVvFWVLkC0TtLwc";
$combined_seed = $server_seed.$client_seed;
echo "Combined seed = $combined_seed\n";
$combined_hash = hash('sha512', $combined_seed);
echo "Hash of combined seed = $combined_hash\n";
$first_four=substr($combined_hash,0,4);
echo "First four characters = $first_four\n";
$hex_to_dec=hexdec($first_four);
echo "Converted to decimal = $hex_to_dec\n";
$weight_array=array(1,17,137,697,2517,6885,14893,26333,39203,50643,58651,63019,64839,65399,65519,65535,65536);
$green_array=array(10,8,6,3,2,1.3,1,0.8,0.5,0.8,1,1.3,2,3,6,8,10);
$red_array=array(20,7,5,3,2,1.1,1,0.6,1,0.6,1,1.1,2,3,5,7,20);
$blue_array=array(50,8,3,2,1.4,1.2,1.1,1,0.4,1,1.1,1.2,1.4,2,3,8,50);
$yellow_array=array(650,30,7,3,1.5,1.2,1,0.7,0.7,0.7,1,1.2,1.5,3,7,30,650);
$i=0;
while ( $hex_to_dec >= $weight_array[$i] ) {
$i++;
}
echo "Green win = \t$green_array[$i]\n";
echo "Red win = \t$red_array[$i]\n";
echo "Blue win = \t$blue_array[$i]\n";
echo "Yellow win = \t$yellow_array[$i]\n";

// Procedure
// 1. Join server and client seeds, server seed first.
// 2. Generate a SHA-512 hash of the string from step 1.
// 3. Convert first FOUR characters of the hash from hexidecimal to decimal.
// 4. Convert result from step 3 to a win per the arrays given.
?>

It's not whether you win or lose; it's whether or not you had a good bet.
Wizard
Administrator
Wizard 
Joined: Oct 14, 2009
  • Threads: 1343
  • Posts: 22216
June 12th, 2020 at 6:50:04 AM permalink
My Minesweeper code seems to be working. I welcome all comments.

<?php
// Minesweeper game conversion for Crypto.Games

$client_seed = "lKB0F28tMdLhrEn6nZ6aJGm9FSZB3bwehn47NhUk";
$server_seed = "nG1QqpFtZFoqJLMl0fE55olfP6KbptpKOInScVh9";
$mines=3;
$step=0;
$mines_found=0;
$position=0;
$combined_seed = $server_seed.$step.$client_seed;
echo "Combined seed = $combined_seed\n";
$combined_hash = hash('sha512', $combined_seed);
echo "Hash of combined seed = $combined_hash\n";
do
{
$first_two=substr($combined_hash,$position,2);
$hex_to_dec=hexdec($first_two);
$mine_location=$hex_to_dec%25;
$repeat=0;
if ($mines_found>0)
{
for ($i=0; $i<$mines_found; $i++)
{
if ( $mine_location == $mine_array[$i])
{ $repeat=1; }
}
}
if ($repeat==0)
{
$mine_array[$mines_found] = $mine_location;
$mines_found++;
echo "Mine at $mine_location\n";
}
$position+=2;
if ($position==128)
{
$position=0;
$step++;
}
}
while ($mines_found<$mines);

// Procedure
// 1. Step the "step" equal to 0 and the "position" to 0.
// 2. Join server and client seeds,step, and server seed, in that order.
// 3. Generate a SHA-512 hash of the string from step 2.
// 4. Convert first two characters, starting at the "position" of the hash from step 3 from hexidecimal to decimal.
// 5. Divide step 4 by 25 and take the remainder.
// 6. If the result from step 5 is unique, for the game, then a mine will be located there.
// 7. Mines locations will be numbered as follows:
// 0 1 2 3 4
// 5 6 7 8 9
// 10 11 12 13 14
// 15 16 17 18 19
// 20 21 22 23 24
// 8. If all mine location have been identified then stop, otherwise, advance the "position" by 2 and go back to 4.
// 9. In the very unlikely event that the "position" reaches 128 (the end of the hash), go increment the "step" by 1, reset the "position" to 0, and go back to step 2.
?>
Last edited by: Wizard on Jun 12, 2020
It's not whether you win or lose; it's whether or not you had a good bet.
Wizard
Administrator
Wizard 
Joined: Oct 14, 2009
  • Threads: 1343
  • Posts: 22216
June 12th, 2020 at 4:42:22 PM permalink
Here is part of the process of choosing the location of a mine in Minesweeper:

1. Using a hashing process explained in the code above, a random integer from 0 to 4095 (16^3-1) is found. Let's call that r.
2. x is divided by 25, the modulo determining the location of a mine. Let's call that mod m.

There are 164 possible values of r that are mapped to all values of m<=20.
There are 163 possible values of r that are mapped to all values of m>=21.

21*164 + 4*163 = 4,096.

In a one-mine game, the probability of it being in any given value of m <= 20 is 0.040039. For values of m >=21, that probability is 0.039795.

21*(164/4096) + 4*(163/4096) = 1.

In a one-mine game, the win for one pick is 1.031 for 1. This makes the return 98.97% for picking square 1 to 20, and 99.00 for 21 to 24.

Keep that in mind if you play.
It's not whether you win or lose; it's whether or not you had a good bet.
Wizard
Administrator
Wizard 
Joined: Oct 14, 2009
  • Threads: 1343
  • Posts: 22216
June 12th, 2020 at 4:53:21 PM permalink
Here is my Roulette link.



<?php
// Roulette game conversion for Crypto.Games
// Enter the Client Seed on line 4 and the Server Seed on line 5.
$client_seed = "b0x6vb0v6TYUIQWF6b0sd6f0y";
$server_seed = "sMDGT5P10m071HAdTQkoYCLJ8vLXnwzq6ugfloMT";
$next_hash = "e7043dd7fe369b94518449d61162a0c960f54781a16548af63194b7fd9d6891a";
$color_array = array(0,1,2,1,2,1,2,1,2,1,2,2,1,2,1,2,1,2,1,1,2,1,2,1,2,1,2,1,2,2,1,2,1,2,1,2,1);
$position=0;
$combined_seed = $server_seed.$client_seed;
echo "Combined seed = $combined_seed\n";
$combined_hash = hash('sha512', $combined_seed);
$server_hash = hash('sha256',$server_seed);
echo "Hash of combined seed = $combined_hash\n";
do
{
$first_two=substr($combined_hash,$position,2);
$hex_to_dec=hexdec($first_two);
$hex_to_dec%=100;
if ($hex_to_dec>36)
{
$position+=2;
}
}
while ($hex_to_dec>36);
echo "Hash of Server Seed =\t $server_hash\n";
echo "Game outcome =\t$hex_to_dec ";
if ($color_array[$hex_to_dec]==0)
{ echo "Green\n"; }
elseif ($color_array[$hex_to_dec]==1)
{ echo "Red\n"; }
else
{ echo "Black\n"; }
$server_hash=hash('sha256', $server_seed);
if ($server_hash==$next_hash)
{ echo "Server Seed match.\n"; }
else
{ echo "<b>SERVER SEED MISMATCH!!!</b>\n"; }

// Procedure
// 1. Set Position equal to 0.
// 2. Join server and client seeds and server seed, in that order.
// 3. Generate a SHA-512 hash of the string from step 2.
// 4. Convert first two characters, starting at the "position" of the hash from step 3 from hexidecimal to decimal.
// 5. If the value from step 4 to 0 to 36, then that will be the game outcome.
// 6. Otherwise, advance the position by 2 and go to step 4.
?>

Last edited by: Wizard on Jun 17, 2020
It's not whether you win or lose; it's whether or not you had a good bet.
Wizard
Administrator
Wizard 
Joined: Oct 14, 2009
  • Threads: 1343
  • Posts: 22216
June 13th, 2020 at 2:03:12 PM permalink


<?php
// Video poker game conversion for Crypto.Games

$server_seed = "9N1XbQTIOGz61t0sGW8Gyb7Nmbr7qO1f01dFkrrg";
$client_seed = "5cEur0NtwPVucqV57p7ugh1y250uosGaltPxNi8Z";
$rank_array=array("A",2,3,4,5,6,7,8,9,10,"J","Q","K");
$suit_array=array("spades","hearts","diamonds","clubs");
$cards_found=0;
$position=0;
$combined_seed = $server_seed.$client_seed;
echo "Combined seed = $combined_seed\n";
$combined_hash = hash('sha512', $combined_seed);
echo "Hash of combined seed = $combined_hash\n";
do
{
$first_two=substr($combined_hash,$position,2);
$hex_to_dec=hexdec($first_two);
if ($hex_to_dec <=207)
{
$repeat=0;
if ($cards_found>0)
{
for ($i=0; $i<$cards_found; $i++)
{
if ( $hex_to_dec == $card_array[$i])
{ $repeat=1; }
}
}
if ($repeat==0)
{
$card_array[$cards_found] = $hex_to_dec;
$cards_found++;
$rank=$hex_to_dec%13;
$suit=intdiv($hex_to_dec,13)%4;
echo "Card at $position\t$first_two\t $hex_to_dec\t";
echo "$rank_array[$rank] of $suit_array[$suit]\n";
}
}
$position+=2;
if ($position==128)
{
echo "Error -- No more space in hash.\n";
$cards_found=10;
}
}
while ($cards_found<10);

// Procedure
// 1. Step the "step" equal to 0 and the "position" to 0.
// 2. Join server and client seeds,step, and server seed, in that order.
// 3. Generate a SHA-512 hash of the string from step 2.
// 4. Convert first two characters, starting at the "position" of the hash from step 3 from hexidecimal to decimal.
// 5. Divide step 4 by 25 and take the remainder.
// 6. If the result from step 5 is unique, for the game, then a mine will be located there.
// 7. Mines locations will be numbered as follows:
// 0 1 2 3 4
// 5 6 7 8 9
// 10 11 12 13 14
// 15 16 17 18 19
// 20 21 22 23 24
// 8. If all mine location have been identified then stop, otherwise, advance the "position" by 2 and go back to 4.
// 9. In the very unlikely event that the "position" reaches 128 (the end of the hash), go increment the "step" by 1, reset the "position" to 0, and go back to step 2.
?>

It's not whether you win or lose; it's whether or not you had a good bet.

  • Jump to: