Improving Our Notebooks to Get Better at Hearts

Dominic DeMarco - SWE
by Dominic DeMarco

650 rounds of lunchtime Hearts, modeled as Chalk features in a Chalk Notebook, with Claude doing most of the setup.

November 23, 2026

Since I started working at Chalk over 2 years ago, we've logged over 650 rounds of Hearts at lunch in a shared spreadsheet. I've played in most of them.

That's a lot of data about my own habits that I’ve never processed anywhere. Recently, we also released Chalk Notebooks, so I put the whole sheet into one to see what it would tell me. Some of it I expected. Some of it, like why I'm so much better at pass-to-the-left rounds, I still can't explain.

Lunch games with a scoreboard

For anyone who hasn't played: Hearts is a four-player trick-taking game, where the goal is to take as few points as possible. Before each round, everyone passes three cards to the left, right, across, or not at all, depending on the round. The highest card in the lead suit wins the trick, and you have to follow suit if you can.

Every heart you take is worth one point, and the queen of spades is 13. However, if you take all 13 hearts and the queen of spades, you shoot the moon! You get -13 points, and everyone else gets 13.

I've roped in 50 coworkers so far, and 20 of them have played more than 40 rounds. Every round goes into the sheet with each player's points, who took and who played the queen, and any moonshot attempts.

Putting Hearts into Chalk features

I could have read the sheet into pandas, generated some matplotlib graphs, and been done here. Instead, I wanted to use the notebook the way a Chalk customer would, on data I actually care about, so I modeled the game as Chalk features on a branch called hearts.

I split the game into four feature classes, from smallest to biggest. HeartsPlayerRound is one player's result in one round, which is where every stat starts. HeartsRound holds the round itself: the game, the pass direction, and a few data-quality notes. HeartsPlayer rolls a player's rounds up into career numbers, plus 30- and 90-day windows so I can see recent form. HeartsLeague is the whole lunch group, so one query can pull everything.

The part I cared about most is that every query is point-in-time. When I ask for someone's stats as of a date, Chalk only counts rounds up to then, so I can replay anyone's career without building a history table myself. In the notebook, that's one offline query per player per lunch day, each with its own as-of time:

as_of = query(
    {"hearts_player.id": [r["player_id"] for r in spine]},
    ["hearts_player.id", "hearts_player.points_per_round", "hearts_player.queen_taken_pct"],
    input_times=end_of_day,
)

Simplified from the notebook. query wraps ChalkClient.offline_query on the hearts branch; end_of_day is 11:59 p.m. on each lunch day.

Letting Claude drive the notebook

Part of the point was to see how a frontier model would use Chalk Notebooks, and whether that experience would be seamless. I asked Claude to do basically everything, from learning the notebook API to creating the branch deployment for the Hearts features.

Most of it worked. Claude set up the client on the hearts branch, installed polars into the kernel so offline queries would run, and built the charts with Altair. Where it got stuck, it got stuck confidently: it inferred CLI commands that don't exist, which burned tokens and sent me back to doing a few steps by hand, like creating the offline query notebook cell type. I had it keep a running list of every rough edge it hit.

Claude worked through the chalk notebook CLI: creating the notebook, adding and running cells, and reading the results back. If your assistant would rather use tools, Chalk's MCP server exposes the same actions, and there's a chalk-notebooks agent skill for assistants that read skills.

Once it's built, hydrating the graphs with the latest data is a single click of “Run all”. When I want a new analysis, I send an agent to add it. The latest one compares how a player does on any stat with and without each other regular at the table, built as a self-join of every player's rounds:

tablemates = flags.select("round_id", "player_id").join(
    flags.select("round_id", "player_id"), on=["round_id"], right_suffix="_other"
).filter(_.player_id != _.player_id_other)

Simplified from the notebook's "With and without each player" cell, written in chalkdf.

My points per round with and without each other regular at the table. The dashed line is my average over all rounds.

What 650 rounds say

The chart I keep coming back to plots every regular's career points per round against the number of rounds they've played. While average points-per-round start quite noisy, as the rounds pile up we converge on a more stable measure of performance. Mine is the long one at the bottom, settling around 4.5 after 610 rounds. Julian, the next most regular player, settles around 6.1 after about 440.

Career points per round by rounds played. Lower is better; lines start at a player's 15th round.

The notebook also breaks every stat out for one player at a time. Here's mine: each panel is one stat, with my career running average in blue and my last 50 rounds in orange.

Every stat I track, by rounds played. Blue is my career running average; orange is my last 50 rounds.

The queen of spades statistics tell quite the story as well. At a four-player table you'd expect to take the queen about a quarter of the time. I take it about 15% of the time (leaving out the queens I take while shooting the moon). When the queen is still in my hand after the pass, I end up taking it about 13% of the time. Most of that is counting cards left in each suit, working out who's void in what, reading the table for who has the queen, and passing cards that set up my hand to get rid of it.

I also shoot the moon more than anyone! I've made 21 of 37 attempts and stopped 28 of other people's moonshots.

I also wanted a single rating, so the notebook runs a multiplayer Elo where every round counts as a head-to-head between each pair at the table. As of November 11 I'm at 1540 and Julian is at 1528, and he's been ahead of me for stretches. All of the rating math runs in chalkdf, with a Python loop stepping through the games in order.

Elo over time for every regular.

The thing I didn't know about my own game

This is the part I can't explain. I average about 3.5 points a round when I pass left and about 5.2 when I pass right. Over hundreds of rounds, that's the gap between my best pass and one of my worst, and I'd never noticed it from inside the game.

My points per round by pass direction.

I would have expected that the no-pass round would be my worst, since I have less control over my starting hand. My only hypothesis is that the queen of spades is more likely to be directly to my left in a pass-to-the-right round (since I rarely pass the queen myself), and the person directly to my left has more opportunities to dump the queen on a trick they know I’m winning.

What we fixed along the way

Using our own product on data that meant something led to fixes I wouldn't have found otherwise.

The first thing that broke was the most obvious query. I asked the league for all of its rounds and player rounds at once, which comes back as a single row holding everything. Notebooks save a preview of every query result, and that one row previewed at about 2 MB. The page crawled. I split it into three flat queries: the ids first, then the rounds, then the player rounds. Flat results preview a capped number of rows, and the page was fast again.

Claude was keeping a list of every point of friction. The default notebook compute was too small for some of the bigger queries, and cells ran out of memory with error messages that made it hard to tell what went wrong. Chart dropdowns didn't work natively, so Claude hacked around them in HTML, and some charts rendered twice. In chalkdf, as-of joins had undocumented preconditions, and there was no unpivot. About 30 PRs came out of this project. The bottleneck has moved: Claude writes PRs faster than the team can review them. Someone else on the team also added the click-to-highlight sidebar to the charts.

What the notebook can't tell me

It can't explain why I do so much worse on the right pass. What it does is tell me where to pay more attention: how often I pass the queen of spades away, and how often it gets passed to me. Those become new columns in the sheet, new features on the branch, and one more click on Run all. Having everything laid out in one notebook is what made the question visible in the first place.

If you want to try this on your own data, start with the Chalk Notebooks docs. For another lunchbreak project, check out our MealBot post that also started over a table at the cafeteria.

Want to stay up-to-date with Chalk?

Subscribe for updates on what we’re building (and shipping!) at Chalk