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
  • Threads: 1518
  • Posts: 27033
Joined: Oct 14, 2009
Thanked by
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
"For with much wisdom comes much sorrow." -- Ecclesiastes 1:18 (NIV)
ThatDonGuy
ThatDonGuy
  • Threads: 122
  • Posts: 6674
Joined: Jun 22, 2011
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
  • Threads: 1518
  • Posts: 27033
Joined: Oct 14, 2009
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.
"For with much wisdom comes much sorrow." -- Ecclesiastes 1:18 (NIV)
Gialmere
Gialmere
  • Threads: 45
  • Posts: 3044
Joined: Nov 26, 2018
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
  • Threads: 1518
  • Posts: 27033
Joined: Oct 14, 2009
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.
"For with much wisdom comes much sorrow." -- Ecclesiastes 1:18 (NIV)
Wizard
Administrator
Wizard
  • Threads: 1518
  • Posts: 27033
Joined: Oct 14, 2009
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.
?>

"For with much wisdom comes much sorrow." -- Ecclesiastes 1:18 (NIV)
Wizard
Administrator
Wizard
  • Threads: 1518
  • Posts: 27033
Joined: Oct 14, 2009
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
"For with much wisdom comes much sorrow." -- Ecclesiastes 1:18 (NIV)
Wizard
Administrator
Wizard
  • Threads: 1518
  • Posts: 27033
Joined: Oct 14, 2009
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.
"For with much wisdom comes much sorrow." -- Ecclesiastes 1:18 (NIV)
Wizard
Administrator
Wizard
  • Threads: 1518
  • Posts: 27033
Joined: Oct 14, 2009
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
"For with much wisdom comes much sorrow." -- Ecclesiastes 1:18 (NIV)
Wizard
Administrator
Wizard
  • Threads: 1518
  • Posts: 27033
Joined: Oct 14, 2009
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.
?>

"For with much wisdom comes much sorrow." -- Ecclesiastes 1:18 (NIV)
Wizard
Administrator
Wizard
  • Threads: 1518
  • Posts: 27033
Joined: Oct 14, 2009
June 13th, 2020 at 4:09:09 PM permalink
Here is my video poker code.


Click on image for larger version.

This was tough, because the game help file is wrong. It took some time figure out what they were doing. They parse the hash two characters at a time and convert them to decimal, as in Minesweeper. They say it will be considered a valid card if this decimal conversion is 0 to 51. What they are really doing is considering it a valid card if the TWO TERMINAL DIGITS are 0 to 51. For example, e0 converts to 224, which would convert to 24, which maps to the Queen of Hearts.



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

$server_seed = "zvEfyCcCLUiHBIqd5WcKXNt9RDpGG7CUMtj88sQE";
$client_seed = "z7K5zg4GXofAJ6TTTvsp2PBilkMVmSzS6lef06Ku";
$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)%100;
if ($hex_to_dec <=51)
{
$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;
$game_position=1+($cards_found%5);
$cards_found++;
$rank=$hex_to_dec%13;
$suit=intdiv($hex_to_dec,13)%4;
if ($cards_found<=5)
{ echo "Deal card $game_position =\t$rank_array[$rank] of $suit_array[$suit]\n"; }
else
{ echo "Draw card $game_position =\t$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 "position" to 0.
// 2. Join server and client seed 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. Take the terminal two digits from from 4.
// 6. If the result from step 5 is 51 or less, and hasn't been found yet, then that will be one of the first ten cards.
// 7. Increment the "position" by 2.
// 8. Keep repeating steps 4 to 7 until ten unique cards are found.
// 9. The first five cards found will be dealt on the deal, starting from left to right.
// 10. The second five cards will be in a queue to be dealt on the draw. For example, if the player draws three cards, then he will get the 6th, 7th, and 8th cards in the queue.
// 11 To get a card position from step 6 to an actual card, do as follows:
// A. Divide the result from step 4 by 13 and take the remainder.
// B. Map the result from step 11A to get the rank, as follows: 0 to A, 1 to 2, 2 to 3, ... , 9 to 10, 10 to J, 11 to Q, 12 to K.
// C. Divide the result from step 4 by 13 and DROP the remainer.
// D. Map the result from step 11C to get the suit, as follows: 0 to spades, 1 to hearts, 2 to diamonds, 3 to clubs.
?>

Last edited by: Wizard on Jun 13, 2020
"For with much wisdom comes much sorrow." -- Ecclesiastes 1:18 (NIV)
Wizard
Administrator
Wizard
  • Threads: 1518
  • Posts: 27033
Joined: Oct 14, 2009
June 13th, 2020 at 5:45:04 PM permalink
Here is my new and improved blackjack code.


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

$server_seed = "UOq310AMOKDvRmEuY1OVhU4EjoiuEwqQSpRc7HlQ";
$client_seed = "a4eft0F19oAFr2H5F18B4gk6dWv7tnmMTkRE1H40";
$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 $cards_found = \t$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<20);

// 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. If the result from step 4 is 0 to 207, then map it to a specific card in a four-deck shoe.
// 6. If the result from step 5 has appeared yet, then that shall be the next card to be dealt in the game.
// 7. To get a card position from step 6 to an actual card, do as follows:
// A. Divide the result from step 4 by 13 and take the remainder.
// B. Map the result from step 7A to get the rank, as follows: 0 to A, 1 to 2, 2 to 3, ... , 9 to 10, 10 to J, 11 to Q, 12 to K.
// C. Divide the result from step 4 by 13 and DROP the remainer.
// D. Divide the result from step 7C by 4 and take the remainder.
// E. Map the result from step 7D to get the suit, as follows: 0 to spades, 1 to hearts, 2 to diamonds, 3 to clubs.
// 8. Keep repeating steps 4 to 7 until you reach the end of the hash, although it is unlikely this many cards will be needed in the game.
?>


Rules:
- 4 decks
- Shuffle after each hand
- Dealer does not peek for blackjack
- Blackjack pays 6:5
- Dealer hits on Soft 17
- Double on any two cards
- Hit split aces
- Early surrender
- Blackjack is paid on split hands
- Double after split allowed
- Player may split once only

Using a combination of my blackjack house edge calculator and blackjack rule variations, I get a house edge of 1.27%.
"For with much wisdom comes much sorrow." -- Ecclesiastes 1:18 (NIV)
ThatDonGuy
ThatDonGuy
  • Threads: 122
  • Posts: 6674
Joined: Jun 22, 2011
June 13th, 2020 at 5:53:01 PM permalink
I did some simulations using your blackjack algorithm, trying to see how often you couldn't get at least 10 different cards out of a hash.

After about 500 million hashes, I was a little surprised that the range of different numbers in 0 to 207 inclusive ran from 35 to 56 (out of a maximum possible 64).

What really surprised me was, about 1 out of every 1000 hashes has 35, and 1 out of every 2000 has 56, but none have 34 or fewer, and none have 57 or more.
Wizard
Administrator
Wizard
  • Threads: 1518
  • Posts: 27033
Joined: Oct 14, 2009
June 13th, 2020 at 6:00:37 PM permalink
Quote: ThatDonGuy

I did some simulations using your blackjack algorithm, trying to see how often you couldn't get at least 10 different cards out of a hash.

After about 500 million hashes, I was a little surprised that the range of different numbers in 0 to 207 inclusive ran from 35 to 56 (out of a maximum possible 64).

What really surprised me was, about 1 out of every 1000 hashes has 35, and 1 out of every 2000 has 56, but none have 34 or fewer, and none have 57 or more.



Very interesting!

Thinking out loud about video poker:
There are 64 possible 2-digit positions in the hash.
The probability of the decimal conversion being 0 to 51 = 208/256 = 81.25%.
Before considering duplicates, there will be an expected 52 cards found.
Given that only ten unique cards are needed, I think the probability of running out is extremely low. Not worth doing the actual math over.
"For with much wisdom comes much sorrow." -- Ecclesiastes 1:18 (NIV)
Wizard
Administrator
Wizard
  • Threads: 1518
  • Posts: 27033
Joined: Oct 14, 2009
June 13th, 2020 at 10:03:45 PM permalink
For my final game, here is my slot machine code.



<?php
// Slot machine conversion for Crypto.Games

$server_seed = "OijoSiL8SYs8HorgShUvdpK30SAYorM2uA29SjBS";
$client_seed = "A2icyCKa0ll6vqmF8Ey0DnpAZE4PUiU8qnspfAAS";
$reel_strip_array=array("Error","Apple","Banana","Cherry","Grapes","Strawberry","Orange","Coin","Peach");
$win_array=array(1000,1500,700,100,100,70,25,11,0);
$reels_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)%10;
if (($hex_to_dec>=1)&&($hex_to_dec<=8))
{
$reels_array[$reels_found] = $hex_to_dec;
$reels_found++;
echo "Reel $reels_found =\t$reel_strip_array[$hex_to_dec]\n";
}
$position+=2;
if ($position==128)
{
echo "Error -- No more space in hash.\n";
$reels_found=5;
}
}
while ($reels_found<5);
$coins=0;
for ($i=0; $i<=4; $i++)
{
if ($reels_array[$i]==7)
{ $coins++; }
}
if ($coins==5)
{ $win=0; }
elseif ( ($reels_array[0]==$reels_array[1]) && ($reels_array[0]==$reels_array[2]) && ($reels_array[0]==$reels_array[3]) && ($reels_array[0]==$reels_array[4]))
{ $win=1; } // five of a kind
elseif ($coins==4)
{ $win=2; }
elseif ((($reels_array[0]==$reels_array[1]) && ($reels_array[0]==$reels_array[2]) && ($reels_array[0]==$reels_array[3])) ||
(($reels_array[0]==$reels_array[1]) && ($reels_array[0]==$reels_array[2]) && ($reels_array[0]==$reels_array[4])) ||
(($reels_array[0]==$reels_array[1]) && ($reels_array[0]==$reels_array[3]) && ($reels_array[0]==$reels_array[4])) ||
(($reels_array[0]==$reels_array[2]) && ($reels_array[0]==$reels_array[3]) && ($reels_array[0]==$reels_array[4])) ||
(($reels_array[1]==$reels_array[2]) && ($reels_array[1]==$reels_array[3]) && ($reels_array[1]==$reels_array[4])))
{ $win=3; } // four of a kind
elseif ($coins==3)
{ $win=4; }
elseif ($coins==2)
{ $win=5; }
elseif ($coins==1)
{ $win=6; }
else
{ $win=7; }
echo "Win =\t$win_array[$win]\n"

// Procedure
// 1. Step the "position" to 0 and "reels found" to 0.
// 2. Join server and client seed 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. Take the terminal digit from from 4.
// 6. If the result from step 5 is 1 to 8, then, map it to a symbol, according to the table below, and increment "reels found" by 1.
// 7. If five reels have been found, then stop, otherwise increment the "position" by 1 and go back to step 4.
// 8. After five reels have been found, display them from left to right, in order that they were found in the Hash.
// 9. Symbol map:
// 1 = Apple
// 2 = Banana
// 3 = Cherry
// 4 = Grapes
// 5 = Strawberry
// 6 = Orange
// 7 = Coin
// 8 = Peach
?>

Last edited by: Wizard on Jun 14, 2020
"For with much wisdom comes much sorrow." -- Ecclesiastes 1:18 (NIV)
ThatDonGuy
ThatDonGuy
  • Threads: 122
  • Posts: 6674
Joined: Jun 22, 2011
June 14th, 2020 at 7:09:23 AM permalink
Question: when you supply the client seed, do you get to see the server seed first, or not?

If you cannot, then I don't see how the server can't read your seed, then generate server seeds until it gets one that results in a loss for the player, and claim that this is the seed.

If you can, then I don't see how you can't do the same thing to determine a winning client seed to use.


Meanwhile, after running the hashing script for video poker, I get a range from 23 to 41 valid cards - but, for some reason, there are never exactly 24 cards, and the probability of getting 40 is only about 2/3 the probability of getting 41.
miplet
miplet
  • Threads: 5
  • Posts: 2140
Joined: Dec 1, 2009
June 14th, 2020 at 10:27:08 AM permalink
Quote: ThatDonGuy

Question: when you supply the client seed, do you get to see the server seed first, or not?

If you cannot, then I don't see how the server can't read your seed, then generate server seeds until it gets one that results in a loss for the player, and claim that this is the seed.

If you can, then I don't see how you can't do the same thing to determine a winning client seed


You get a hash of the server seed before you bet.
“Man Babes” #AxelFabulous
Wizard
Administrator
Wizard
  • Threads: 1518
  • Posts: 27033
Joined: Oct 14, 2009
June 14th, 2020 at 6:28:51 PM permalink
Quote: miplet

You get a hash of the server seed before you bet.



Exactly. In other words, the casino's seed is predetermined before you bet and the hash of that seed proves it. That still doesn't mean you can't get cheated. I will write much more about it soon.
"For with much wisdom comes much sorrow." -- Ecclesiastes 1:18 (NIV)
Wizard
Administrator
Wizard
  • Threads: 1518
  • Posts: 27033
Joined: Oct 14, 2009
Thanked by
thefinalsix
June 15th, 2020 at 2:05:21 PM permalink
I'm starting to migrate this material to WoO. I've improved my page on Dice quite a bit to explain how the game outcome is determined and providing my program to help with that.

"For with much wisdom comes much sorrow." -- Ecclesiastes 1:18 (NIV)
Wizard
Administrator
Wizard
  • Threads: 1518
  • Posts: 27033
Joined: Oct 14, 2009
June 17th, 2020 at 12:59:38 PM permalink
How can one quote "<?php" (without the quotation marks) in HTML without it interpreting it as PHP code?

This has been driving me crazy for hours?
"For with much wisdom comes much sorrow." -- Ecclesiastes 1:18 (NIV)
ThatDonGuy
ThatDonGuy
  • Threads: 122
  • Posts: 6674
Joined: Jun 22, 2011
June 17th, 2020 at 1:09:52 PM permalink
Quote: Wizard

How can one quote "<?php" (without the quotation marks) in HTML without it interpreting it as PHP code?

This has been driving me crazy for hours?


What do you mean by "quote"?
If you want the page to show "<?php", try (without the spaces): & l t ; ? p h p
Wizard
Administrator
Wizard
  • Threads: 1518
  • Posts: 27033
Joined: Oct 14, 2009
June 17th, 2020 at 2:43:12 PM permalink
Quote: ThatDonGuy

What do you mean by "quote"?
If you want the page to show "<?php", try (without the spaces): & l t ; ? p h p



I tried using all HTML characters, like <, but they got converted to the actual characters, so that didn't work (as it just did in this post).

Yes, I could separate the PHP with spaces, but I'm afraid someone would try to actually execute the code and it wouldn't run because of the spaces.
"For with much wisdom comes much sorrow." -- Ecclesiastes 1:18 (NIV)
ThatDonGuy
ThatDonGuy
  • Threads: 122
  • Posts: 6674
Joined: Jun 22, 2011
June 17th, 2020 at 2:49:19 PM permalink
I am still confused as to just what it is you are trying to do. You manage to put "<?php" in your existing code scripts in this thread without any apparent problem.
Wizard
Administrator
Wizard
  • Threads: 1518
  • Posts: 27033
Joined: Oct 14, 2009
June 17th, 2020 at 4:02:06 PM permalink
Quote: ThatDonGuy

I am still confused as to just what it is you are trying to do. You manage to put "<?php" in your existing code scripts in this thread without any apparent problem.



This forum let's me do that, because the forum part is not in HTML. I am trying to quote code at WoO.

For example, scroll to the bottom of my Dice page and click the spoiler button. You can see I had to resort to including an image of <?php, because I wrote it out, the page would try to run the code.

No, putting it in code or pre tags doesn't help, that command supersedes those codes.
"For with much wisdom comes much sorrow." -- Ecclesiastes 1:18 (NIV)
Wizard
Administrator
Wizard
  • Threads: 1518
  • Posts: 27033
Joined: Oct 14, 2009
June 17th, 2020 at 4:14:31 PM permalink
I'm proud to announce my new page on Video Poker (Encrypted Version). I welcome all comments.
"For with much wisdom comes much sorrow." -- Ecclesiastes 1:18 (NIV)
ThatDonGuy
ThatDonGuy
  • Threads: 122
  • Posts: 6674
Joined: Jun 22, 2011
June 17th, 2020 at 6:18:03 PM permalink
Quote: Wizard

This forum let's me do that, because the forum part is not in HTML. I am trying to quote code at WoO.

For example, scroll to the bottom of my Dice page and click the spoiler button. You can see I had to resort to including an image of <?php, because I wrote it out, the page would try to run the code.

No, putting it in code or pre tags doesn't help, that command supersedes those codes.



How about something like

<?php echo '<?php'; ?>
Wizard
Administrator
Wizard
  • Threads: 1518
  • Posts: 27033
Joined: Oct 14, 2009
June 17th, 2020 at 6:49:24 PM permalink
Quote: ThatDonGuy


How about something like

<?php echo '<?php'; ?>



I tried that and it messed up everything. We've got PHP inside of pre tags inside of HTML inside of whatever editor is used and it is just a mess. I am looking something like a simple backslash character to override a character in a command.
"For with much wisdom comes much sorrow." -- Ecclesiastes 1:18 (NIV)
ThatDonGuy
ThatDonGuy
  • Threads: 122
  • Posts: 6674
Joined: Jun 22, 2011
June 17th, 2020 at 7:54:21 PM permalink
Apparently, there's a class called "notranslate" that might solve the problem.

Try:
<div class="notranslate">&- lt;?php ?&- gt;</div>
except that the two dashes are removed

The problem is, I don't know if you can use <code>...</code> with it.
miplet
miplet
  • Threads: 5
  • Posts: 2140
Joined: Dec 1, 2009
June 17th, 2020 at 8:56:54 PM permalink
Try
x#38;#60;?php
where x is &
You will need to do this every time you edit the page.
“Man Babes” #AxelFabulous
Wizard
Administrator
Wizard
  • Threads: 1518
  • Posts: 27033
Joined: Oct 14, 2009
June 17th, 2020 at 9:11:18 PM permalink
Quote: ThatDonGuy

Apparently, there's a class called "notranslate" that might solve the problem.

Try:
<div class="notranslate">&- lt;?php ?&- gt;</div>
except that the two dashes are removed

The problem is, I don't know if you can use <code>...</code> with it.



Thanks, but that really messed things up, and I have no idea why. Fortunately, I saved the previous copy.
"For with much wisdom comes much sorrow." -- Ecclesiastes 1:18 (NIV)
Wizard
Administrator
Wizard
  • Threads: 1518
  • Posts: 27033
Joined: Oct 14, 2009
June 17th, 2020 at 9:22:26 PM permalink
Quote: miplet

Try
x#38;#60;?php
where x is &
You will need to do this every time you edit the page.



That caused quite a mess when I tried that. I don't even want to talk about it.

No matter how I try to disguise <?php in HTML (fortunately this isn't HTML here), the page unscrambles it and tries to run it.
The only thing that has worked is to take a screenshot of it and post the image.
"For with much wisdom comes much sorrow." -- Ecclesiastes 1:18 (NIV)
ThatDonGuy
ThatDonGuy
  • Threads: 122
  • Posts: 6674
Joined: Jun 22, 2011
June 18th, 2020 at 11:21:30 AM permalink
Quote: Wizard

No matter how I try to disguise <?php in HTML (fortunately this isn't HTML here), the page unscrambles it and tries to run it.
The only thing that has worked is to take a screenshot of it and post the image.


I know it can be done, because this page does it (look at the fifth line of the example).

The text is defined in a <div class="w3-code htmlHigh notranslate"> block.
w3-code is defined as:
span.marked {
color:#e80000;
background-color:transparent;
}
However, I don't know what "htmlHigh" is, and can't find a reference to it anywhere.
Wizard
Administrator
Wizard
  • Threads: 1518
  • Posts: 27033
Joined: Oct 14, 2009
June 18th, 2020 at 11:26:26 AM permalink
Thanks. I'm short on time at the moment, but will try this on some test code.
"For with much wisdom comes much sorrow." -- Ecclesiastes 1:18 (NIV)
Wizard
Administrator
Wizard
  • Threads: 1518
  • Posts: 27033
Joined: Oct 14, 2009
June 18th, 2020 at 5:26:19 PM permalink
Quote: ThatDonGuy

I know it can be done, because this page does it (look at the fifth line of the example).

The text is defined in a <div class="w3-code htmlHigh notranslate"> block.
w3-code is defined as:
span.marked {
color:#e80000;
background-color:transparent;
}
However, I don't know what "htmlHigh" is, and can't find a reference to it anywhere.



I tried that as best I could and that dreaded <?php line of code didn't appear at all.
"For with much wisdom comes much sorrow." -- Ecclesiastes 1:18 (NIV)
miplet
miplet
  • Threads: 5
  • Posts: 2140
Joined: Dec 1, 2009
June 18th, 2020 at 6:25:14 PM permalink
My last attempt is using JavaScript

<script>
document.write("<","?php");
</script>
“Man Babes” #AxelFabulous
Wizard
Administrator
Wizard
  • Threads: 1518
  • Posts: 27033
Joined: Oct 14, 2009
June 19th, 2020 at 5:57:52 AM permalink
Quote: miplet

My last attempt is using JavaScript

<script>
document.write("<","?php");
</script>



Not only did that not display the intended line, but it screwed up the formatting of the rest of the code.
"For with much wisdom comes much sorrow." -- Ecclesiastes 1:18 (NIV)
ThatDonGuy
ThatDonGuy
  • Threads: 122
  • Posts: 6674
Joined: Jun 22, 2011
June 19th, 2020 at 7:08:51 AM permalink
I came across another example where using "echo <?php" works. I have a feeling there's some setting on your host's web server that is messing things up.

Try this, but replace the colons with semicolons:
<?php
echo "&lt:?php echo '&lt:?php&gt:'; ?&gt:";
?>
Wizard
Administrator
Wizard
  • Threads: 1518
  • Posts: 27033
Joined: Oct 14, 2009
June 19th, 2020 at 9:21:09 AM permalink
Quote: ThatDonGuy

I came across another example where using "echo <?php" works. I have a feeling there's some setting on your host's web server that is messing things up.

Try this, but replace the colons with semicolons:

<?php
echo "&lt:?php echo '&lt:?php&gt:'; ?&gt:";
?>



Thanks, but if I try to call PHP code, it doesn't work, but can mess things up. For example, just

<?php
echo "Too many cooks in the kitchen spoil the broth.";
?>

Will show nothing at all.
"For with much wisdom comes much sorrow." -- Ecclesiastes 1:18 (NIV)
Wizard
Administrator
Wizard
  • Threads: 1518
  • Posts: 27033
Joined: Oct 14, 2009
June 19th, 2020 at 1:35:08 PM permalink
Mainly for my own benefit, I want to document updates to my scripts:

video poker 6-19-20
blackjack 6-19
slot machine 6-23-20
Last edited by: Wizard on Jun 23, 2020
"For with much wisdom comes much sorrow." -- Ecclesiastes 1:18 (NIV)
ThatDonGuy
ThatDonGuy
  • Threads: 122
  • Posts: 6674
Joined: Jun 22, 2011
June 19th, 2020 at 3:40:54 PM permalink
Quote: Wizard

Thanks, but if I try to call PHP code, it doesn't work, but can mess things up. For example, just

<?php
echo "Too many cooks in the kitchen spoil the broth.";
?>

Will show nothing at all.


If that is the case, then I have a feeling it's a configuration problem on the server side.
Since you are using an image for the initial <?php tag, so the viewers can't cut-and-paste it anyway, I suggest the first two lines be the following:
<-?php
// ** Remove the dash from the above line before running the script **
Wizard
Administrator
Wizard
  • Threads: 1518
  • Posts: 27033
Joined: Oct 14, 2009
June 19th, 2020 at 4:06:39 PM permalink
Yeah, I did something similar at first. Maybe I should go back to it, as opposed to the image of one line of code.
"For with much wisdom comes much sorrow." -- Ecclesiastes 1:18 (NIV)
Wizard
Administrator
Wizard
  • Threads: 1518
  • Posts: 27033
Joined: Oct 14, 2009
June 22nd, 2020 at 5:42:23 AM permalink
Just put up my page on Blackjack (Encrypted Version). I welcome all comments.
"For with much wisdom comes much sorrow." -- Ecclesiastes 1:18 (NIV)
  • Jump to: