← Be the Model

The Casino Job

Chapter 5, part two: a card-counting neuron at the blackjack table

Press Run and the page plays a hundred thousand hands of single-deck blackjack. Two players bet on every hand. They don't play their own hands: one hand is dealt, both players bet on it, and they win or lose together. They differ only in how much they bet.

The counting player reads the running count from the neuron in part one (weights +1 for 2 to 6, 0 for 7 to 9, −1 for 10 to ace, bias 0, no ReLU) before each hand. The deck is reshuffled when fewer than fifteen cards are left, and that resets the neuron's inputs, so the count goes back to 0. A blackjack pays one and a half times the bet, the dealer stands on 17, and the hand is played by basic strategy, including doubling down and splitting.

1
Flat player
Bets 1 on every hand
0
5
Counting player
Bets 1 below +2, and 5 at +2 or higher
0
Hands played: 0 of 100,000

Each player's money

Flat playerCounting player

Your lines will look different every run, because every run deals different cards. The counting player usually finishes ahead, but can finish behind even when the page works correctly.

Average bet at each count

Count when betHandsFlatCounting

The count is recorded at the moment each bet is placed. The flat player's average should be 1 everywhere; the counting player's should be 1 below +2 and 5 from +2 up.