RareMinerals
RareMinerals
  • Threads: 1
  • Posts: 7
Joined: Mar 12, 2024
March 12th, 2024 at 12:49:08 PM permalink
I have some questions about an old article on free bet blackjack
Link: /games/free-bet-blackjack/#pot-of-gold
I'm attempting to run a combinatorial analysis (by simulation) of the pot of gold side bet. However, when I run my simulation, it shows a house edge of 14.8%, a whole decimal place off of what the wizard published in his article.
This is the first time I've attempted to run a simulation like this, so I suspect it's my math that's the problem, not the wizard's. However, neither I nor any of my programmer friends who've tried to help me can figure out what the problem is.
Right now, I'm running a simulation of 100,000,000 hands, keeping track of the winnings from each, and dividing the total winnings by 100,000,000 at the end.

Am I making some obvious beginners mistake? Could someone with a little more experience point me in the right direction?

I can also provide the exact code I've written to do the sim if that would help.
Dieter
Administrator
Dieter
  • Threads: 16
  • Posts: 5558
Joined: Jul 23, 2014
March 12th, 2024 at 1:29:31 PM permalink
Link: https://wizardofodds.com/games/free-bet-blackjack/#pot-of-gold

14.8% is significantly different than either 5.76% or 4.64%. I'm inclined to think it's not a mere simple error.
May the cards fall in your favor.
RareMinerals
RareMinerals
  • Threads: 1
  • Posts: 7
Joined: Mar 12, 2024
March 12th, 2024 at 1:40:25 PM permalink
Sorry, I should have specified. my simulation splits 5's, and is using paytable 2. In the paragraph right before the acknowledgements is where he gives the 1.48% figure.
Dieter
Administrator
Dieter
  • Threads: 16
  • Posts: 5558
Joined: Jul 23, 2014
March 12th, 2024 at 1:46:39 PM permalink
Ahh, then one of your numbers is 1/10th of what it should be? ;)

(Without seeing what you're doing... how could someone tell what's going wrong?)
May the cards fall in your favor.
Mental
Mental
  • Threads: 13
  • Posts: 1296
Joined: Dec 10, 2018
March 12th, 2024 at 1:52:38 PM permalink
Quote: RareMinerals

I have some questions about an old article on free bet blackjack
Link: /games/free-bet-blackjack/#pot-of-gold
I'm attempting to run a combinatorial analysis (by simulation) of the pot of gold side bet. However, when I run my simulation, it shows a house edge of 14.8%, a whole decimal place off of what the wizard published in his article.
This is the first time I've attempted to run a simulation like this, so I suspect it's my math that's the problem, not the wizard's. However, neither I nor any of my programmer friends who've tried to help me can figure out what the problem is.
Right now, I'm running a simulation of 100,000,000 hands, keeping track of the winnings from each, and dividing the total winnings by 100,000,000 at the end.

Am I making some obvious beginners mistake? Could someone with a little more experience point me in the right direction?

I can also provide the exact code I've written to do the sim if that would help.
link to original post

Check to be sure you are not overflowing an integer variable. A 32-bit signed integer can only count up to 2 billion before it overflows and goes negative. Unsigned int will overflow at 4 billion. If you are summing a very large number of values and dividing at the end, you could very well be overflowing the winning sum variable.
This forum is more enjoyable after I learned how to use the 'Block this user' button.
RareMinerals
RareMinerals
  • Threads: 1
  • Posts: 7
Joined: Mar 12, 2024
March 12th, 2024 at 2:06:27 PM permalink
Haha, good point.

One of my numbers is 10 times what it should be.


for (let i = 0; i <= 100000000; i++){
totalEarnings += playHand(deck);
}
console.log(totalEarnings/100000000);


Above is the code I run to sim the hands and return the results. I expect it to return -0.0148 . . . based on wizard's published numbers, but instead it returns -0.148 . . . which seems to show a house edge ten times what it should be.

when I run the playHand function, individual runs seem to be ok. Nothing is being returned at 10 times it's value. Just in case there's an error I'll post that as well.


function playHand(originalShoe) {

var freeBet = 0;
var winnings;
var shoe = originalShoe.slice(0);
const handOne = [15,16], handTwo = [15,16], handThree = [15,16], handFour = [15,16];

shoe = shuffle(shoe);
handOne[0] = shoe.pop();
handOne[1] = shoe.pop();

//Code block that handles splits
if (handOne[0] != 10 && handOne[0] != 11 && handOne[0] != 12 && handOne[0] != 13)
{

if (handOne[0] == handOne[1]) // First split
{
freeBet++;
handTwo[0] = handOne[0];
handOne[1] = shoe.pop();
handTwo[1] = shoe.pop();
}

if (handOne[0] == handOne[1]) // second split
{
freeBet++;
handThree[0] = handOne[0];
handOne[1] = shoe.pop();
handThree[1] = shoe.pop();
} else if (handTwo[0] == handTwo[1]) {
freeBet++;
handThree[0] = handTwo[0];
handTwo[1] = shoe.pop();
handThree[1] = shoe.pop();
}

if (handOne[0] == handOne[1]) // final split
{
freeBet++;
handFour[0] = handOne[0];
handOne[1] = shoe.pop();
handFour[1] = shoe.pop();
} else if (handTwo[0] == handTwo[1]) {
freeBet++;
handFour[0] = handTwo[0];
handTwo[1] = shoe.pop();
handFour[1] = shoe.pop();
} else if (handThree[0] == handThree[1]) {
freeBet++;
handFour[0] = handThree[0];
handThree[1] = shoe.pop();
handFour[1] = shoe.pop();
}

}


//Check for free doubles
if (handOne[0] + handOne[1] == 9 || handOne[0] + handOne[1] == 10 || handOne[0] + handOne[1] == 11)
{
freeBet++;
}

if (handTwo[0] + handTwo[1] == 9 || handTwo[0] + handTwo[1] == 10 || handTwo[0] + handTwo[1] == 11)
{
freeBet++;
}

if (handThree[0] + handThree[1] == 9 || handThree[0] + handThree[1] == 10 || handThree[0] + handThree[1] == 11)
{
freeBet++;
}

if (handFour[0] + handFour[1] == 9 || handFour[0] + handFour[1] == 10 || handFour[0] + handFour[1] == 11)
{
freeBet++;
}

switch (freeBet) {
case 0:
winnings = -1;
break;
case 1:
winnings = 3;
break;
case 2:
winnings = 12;
break;
case 3:
winnings = 30;
break;
case 4:
winnings = 50;
break;
case 5:
winnings = 100;
break;
case 6:
winnings = 100;
break;
case 7:
winnings = 100;
break;
default:
console.log("Error: too many free bets");
break;
}

/* Debug logs
console.log("hand one " + handOne)
console.log("hand two " + handTwo)
console.log("hand three " + handThree)
console.log("hand four " + handFour)
console.log(freeBet);
console.log("");
console.log("");
console.log("");
*/

return winnings;


It's a little clunky, but it should be sound.
Last edited by: RareMinerals on Mar 12, 2024
RareMinerals
RareMinerals
  • Threads: 1
  • Posts: 7
Joined: Mar 12, 2024
March 12th, 2024 at 2:07:42 PM permalink
Thanks for the advice. I checked, and I don't think I have an integer overflow issue. I've run the sim with lower numbers like 1,000,000, which should prevent the winnings from reaching the billions, even if you win the 100 jackpot every time.
Mental
Mental
  • Threads: 13
  • Posts: 1296
Joined: Dec 10, 2018
March 12th, 2024 at 2:30:22 PM permalink
Quote: RareMinerals

Haha, good point.

One of my numbers is 10 times what it should be.


for (let i = 0; i <= 100000000; i++){
totalEarnings += playHand(deck);
}
console.log(totalEarnings/100000000);

link to original post

Counting zeroes is prone to error. This is a good reason to always define large numbers once.
int nHands = 100000000;
for (let i = 0; i <= nHands ; i++){
totalEarnings += playHand(deck);
}
console.log(totalEarnings/nHands);
This forum is more enjoyable after I learned how to use the 'Block this user' button.
RareMinerals
RareMinerals
  • Threads: 1
  • Posts: 7
Joined: Mar 12, 2024
March 12th, 2024 at 2:46:10 PM permalink
Thanks Mental. I've added that to the program. The issue still persists, but it'll be a lot easier to update and test things now.
DogHand
DogHand
  • Threads: 2
  • Posts: 1529
Joined: Sep 24, 2011
March 12th, 2024 at 3:46:09 PM permalink
Quote: RareMinerals

Thanks Mental. I've added that to the program. The issue still persists, but it'll be a lot easier to update and test things now.
link to original post


RareMinerals,

Can you add variables to count the number of times the round ends with 0, 1, ... 7 free bets? Maybe name these NFB[0], NFB[1], ... NFB[7]. At the end of the sim, output each of these divided by the number of rounds. This will allow you to compare your probability for each outcome with the Wiz's values. Also, don't forget to check that the sum of the NFB's equals the number of rounds.

Hope this helps!

Dog Hand
ThatDonGuy
ThatDonGuy 
  • Threads: 117
  • Posts: 6284
Joined: Jun 22, 2011
March 12th, 2024 at 3:46:35 PM permalink
I noticed two things, mainly involving your checking for free doubles.

First, it looks like any card (e.g. handOne[0]) can be any integer from 1 to 13, so you may be counting face cards as more than 10, which means you are missing on quite a few doubles.

Second, your check for free doubles is always checking four hands, even when you do not split.
RareMinerals
RareMinerals
  • Threads: 1
  • Posts: 7
Joined: Mar 12, 2024
March 12th, 2024 at 4:09:24 PM permalink
Quote: DogHand

Quote: RareMinerals

Thanks Mental. I've added that to the program. The issue still persists, but it'll be a lot easier to update and test things now.
link to original post


RareMinerals,

Can you add variables to count the number of times the round ends with 0, 1, ... 7 free bets? Maybe name these NFB[0], NFB[1], ... NFB[7]. At the end of the sim, output each of these divided by the number of rounds. This will allow you to compare your probability for each outcome with the Wiz's values. Also, don't forget to check that the sum of the NFB's equals the number of rounds.

Hope this helps!

Dog Hand
link to original post



When I track the probability of the number of free bets, there my numbers match wizard's. 0: 0.83, 1: 0.14, 2: 0.013, etc.
I've also set up a quick tracker to make sure that the correct number of rounds is being run. I did have an off by one error, running 100,000,001 times and only dividing by 100,000,000, but I don't think this accounts for the error being so large.
RareMinerals
RareMinerals
  • Threads: 1
  • Posts: 7
Joined: Mar 12, 2024
March 12th, 2024 at 4:12:24 PM permalink
Quote: ThatDonGuy

I noticed two things, mainly involving your checking for free doubles.

First, it looks like any card (e.g. handOne[0]) can be any integer from 1 to 13, so you may be counting face cards as more than 10, which means you are missing on quite a few doubles.

Second, your check for free doubles is always checking four hands, even when you do not split.
link to original post



Counting face cards as 10, 11, 12 etc is intentional behavior. Because you can only free double on hard totals of 9, 10, or 11, no hand that contains an ace or 10 can get a free double.

Checking the empty hands isn't the most efficient way to do the simulation, but it shouldn't result in any additional free bets being awarded, as the empty hands will never split or double. It definitely slows down the program, but shouldn't create any math errors.
  • Jump to: