March 23rd, 2015 at 7:40:57 PM
permalink
Hi all,
Someone may ask the similar question before but I didn't find the answer from this forum so I would like to state my doubt again here.
I am trying to simulation the blackjack game with basic strategy. My reference to the house edge is https://wizardofodds.com/games/blackjack/calculator/ . I try to simulate 1deck game, wizard of odds show me edge to be 0.23%
The frame of my simulation look like the following
With my code, I got number very close to the wizard of odds. In other resources, I saw someone do the simulation by control the card dealt to player and dealer in a loop and randomize the card deal to other actions.
With 3 cards, total combination # is 2197, each combination card1-card2-card3 occurs at the probability P=1/2197, denote bets for each combination B(n), wins for each combination W(n), so I am calculating the house edge as
house edge = 1 - sum(P*B(n)/W(n)) on all n=1 to 2197)
But this value is not the same as the one calculated by "house edge = 1 - totalwin/totalbet"; I mean they are not even close. This method give 1.8% edge but the previous one give 0.23%. I wonder what's wrong with my math?
Someone may ask the similar question before but I didn't find the answer from this forum so I would like to state my doubt again here.
I am trying to simulation the blackjack game with basic strategy. My reference to the house edge is https://wizardofodds.com/games/blackjack/calculator/ . I try to simulate 1deck game, wizard of odds show me edge to be 0.23%
The frame of my simulation look like the following
for (long n=0; <10000000; n++)
{
// for player
card1 = random card from deck;
card2 = random card from deck;
// for dealer
card3 = random card from deck;
card4 = random card from deck;
// here we follow the basic strategy table to decide next action on hit/stand/double/split/...
totalbet += single bet
totalwin += single win
}
house edge = 1 - totalwin/totalbet;
With my code, I got number very close to the wizard of odds. In other resources, I saw someone do the simulation by control the card dealt to player and dealer in a loop and randomize the card deal to other actions.
for (card1=1 to 13)
{
for (card2=1 to 13)
{
for (card3=1 to 13)
{
for (long n=0 to 10000000)
{
// for player
// assign card1 and card2 to player
// for dealer
//assign card3 to delaer
card4 = random card from deck and assign it to dealaer
// here we follow the basic strategy table to decide next action on hit/stand/double/split/...
totalbet += single bet
totalwin += single win
// record the bets and wins against the card1, card2 and card3, output data looks like, e.g.
// card1 card2 card3 bets wins
// 1 2 5 1022 3234
}
}
}
}
With 3 cards, total combination # is 2197, each combination card1-card2-card3 occurs at the probability P=1/2197, denote bets for each combination B(n), wins for each combination W(n), so I am calculating the house edge as
house edge = 1 - sum(P*B(n)/W(n)) on all n=1 to 2197)
But this value is not the same as the one calculated by "house edge = 1 - totalwin/totalbet"; I mean they are not even close. This method give 1.8% edge but the previous one give 0.23%. I wonder what's wrong with my math?
March 23rd, 2015 at 10:06:00 PM
permalink
This is not my area of expertise. So I have a fair chance of being helpful, and a much greater chance of saying something stupid.
I'm having trouble with your statement of 3 cards combo is 2197. I get 3 card combo is 132600, because even though the card1-2-3 are valued by rank, you're still taking 1 random of 52, then 1 random of 51, then 1 random of 50. Whether the suits are marked on the cards or not, you're still picking from that base set of 4 cards per rank and can receive more than 1 card of a rank. So your P should equal 1/132600, and perhaps your n should cycle from 1 to 132600 (or perhaps your n at 2197 is correct for that part).
I'm having trouble with your statement of 3 cards combo is 2197. I get 3 card combo is 132600, because even though the card1-2-3 are valued by rank, you're still taking 1 random of 52, then 1 random of 51, then 1 random of 50. Whether the suits are marked on the cards or not, you're still picking from that base set of 4 cards per rank and can receive more than 1 card of a rank. So your P should equal 1/132600, and perhaps your n should cycle from 1 to 132600 (or perhaps your n at 2197 is correct for that part).
If the House lost every hand, they wouldn't deal the game.
March 23rd, 2015 at 10:51:45 PM
permalink
Quote: beachbumbabsThis is not my area of expertise. So I have a fair chance of being helpful, and a much greater chance of saying something stupid.
I'm having trouble with your statement of 3 cards combo is 2197. I get 3 card combo is 132600, because even though the card1-2-3 are valued by rank, you're still taking 1 random of 52, then 1 random of 51, then 1 random of 50. Whether the suits are marked on the cards or not, you're still picking from that base set of 4 cards per rank and can receive more than 1 card of a rank. So your P should equal 1/132600, and perhaps your n should cycle from 1 to 132600 (or perhaps your n at 2197 is correct for that part).
I think this is right, you need to do 1 card from 52, 1 card from 51, 1 card from 50. Because if you are saying card 1 is from 13, card 2 is from 13, card 3 is from 13, essentially what you are saying is: Let card 1 be a heart, let card 2 be a spade, let card 3 be a club.