3

I'm writing a java project for the university where am I exploring blackjack from the math point of view. Right now I've stumbled upon the probability of dealer busting (depending on the up card) for 8 decks in a shoe.

odds

So I got those results through the millions of simulations (each time deck is different, full and reshuffled). As you can see, the odds that I've acquired with my application and the correct ones (from the wizardofodds.com website) are quite similar from TWO to NINE. But there's something wrong about TEN and ACE. The difference is just too much to be ignored. So can somebody please explain to me what am I missing?

Below I've attached necessary source codes for this issue (I've excluded a lot of other methods from classes that are not related).

Would appreciate any help so much. Thank you in advance for reading this.

Main class

public static void main(String[] args) {
    for (Value value : Value.values()) 
        Card card = new Card(value);
        int range = 1_000_000;
        long res = IntStream.range(0, range).sequential().filter(e -> isBusted(card)).count();
        System.out.println(value + "\t" + res * 1.0 / range);
    }
}

public static boolean isBusted(Card card) {
    Deck deck = new Deck();
    deck.init(8);
    Hand hand = new Hand(card);
    while (hand.points() < 17) {
        hand.add(deck.draw());
    }
    return hand.points() > 21;
}

Part of the Deck class

public class Deck {
    private ArrayList<Card> cards;

    public Deck() {
        cards = new ArrayList<>();
        init(8);
    }

    public void init(int size) {
        cards.clear();
        for (int i = 0; i < size; i++) {
            for (Suit suit : Suit.values()) {
                for (Value value : Value.values()) {
                    cards.add(new Card(suit, value));
                }
            }
        }
        Collections.shuffle(cards);
    }

    public Card draw() {
        Card card = cards.get(0);
        cards.remove(card);
        return card;
    }
}

Part of the Hand class

public class Hand {
    private ArrayList<Card> cards;

    public Hand(Card... cards) {
        this.cards = new ArrayList<>(Arrays.asList(cards));
    }

    public void add(Card card) {
        this.cards.add(card);
    }

    public int countAces() {
        return (int) cards.stream().filter(Card::isAce).count();
    }

    public int points() {
        int points = cards.stream().mapToInt(e -> e.value().points()).sum();
        for (int i = 0; i < countAces(); i++) {
            points += (points >= 11) ? 1 : 11;
        }
        return points;
    }
}

Part of the Card class

public class Card {
    private Suit suit;
    private Value value;

    public Card(Value value) {
        this.suit = Suit.CLUBS;
        this.value = value;
    }

    public Value value() {
        return value;
    }

    public boolean isAce() {
        return value.equals(Value.ACE);
    }
}

Part of the Value class

public enum Value {
    TWO, THREE, FOUR, FIVE, SIX, SEVEN, EIGHT, NINE, TEN, JACK, QUEEN, KING, ACE;

    public int points() {
        if (ordinal() <= 7) {
            return ordinal() + 2;
        }
        if (ordinal() >= 8 && ordinal() <= 11) {
            return 10;
        } else {
            return 0;
        }
    }
}
weston
  • 54,145
  • 21
  • 145
  • 203
Aether
  • 41
  • 4
  • Maybe it's that you have the first card not being drawn from the deck? With 8 packs, there are 32 10s and Aces; If the first card is a 10 or Ace, there should be 31 left (fewer than the undrawn values), but isBusted() starts with all 32. – racraman Dec 17 '18 at 00:39
  • Thank you for your answer. I was thinking about this too. But when I've tried to draw the card from the deck and calculate it accordingly, the odds got even worse. So I decided to not include this until I come up with the solution for Aces and Tens. – Aether Dec 17 '18 at 01:27

3 Answers3

3

The probabilities you compare to, are derived from the assumptions (under typical US rules), that the dealer doesn't have natural. In a typical US game, when the dealer's upcard is Ace, the hole card can't be Ten; and when the upcard is Ten, the hole card can't be Ace.

If you still interested in obtaining the matching result, you can use the following conditional probability formula:

Q[bust] = P[bust] / (1 - P[bj])

where

  • Q are the probabilities for the dealer under US rules (note, that Q[bj]=0);
  • P are the probabilities for the dealer under EU rules.

According to https://wizardofodds.com/games/blackjack/dealer-odds-blackjack-european-rules (for 8 decks):

  • P[bj|upcard=Ace]=0.308434
  • P[bj|upcard=10]=0.0771084
dimakura
  • 7,575
  • 17
  • 36
1

All looks good, but you're missing a case that deals with aces specifically.

At most tables the dealer also hits on a "soft" 17, i.e. a hand containing an ace and one or more other cards totalling six.

From wikipedia.org/wiki/Blackjack.

Because you always stop on every 17, you will have lower odds of busting.

while (hand.points() < 17 || hand.soft17()) {
    hand.add(deck.draw());
}

This would affect odds in every case, though it's funny it has such an effect on the 10s. So may not be the only issue.

weston
  • 54,145
  • 21
  • 145
  • 203
  • Hey! Thank you very much for your answer. You're totally right, but, unfortunately, that's not the case, because this is for "Dealer Stands On Soft 17" case only. There are two tables on the https://wizardofodds.com/games/blackjack/side-bets/bet-the-bust/ and I've chosen the correct one. – Aether Dec 17 '18 at 01:22
0

Oh my god. Seems that everything is correct. I was just looking at the weird table with odds. Not sure anymore what is https://wizardofodds.com/games/blackjack/side-bets/bet-the-bust/, but comparing to the https://wizardofodds.com/games/blackjack/appendix/2b/ it looks pretty fine.

I'm sorry. Thanks to everyone who tried to help me.

Aether
  • 41
  • 4