2026-07-13 · 5 MIN READ
The hand is not the board
Everyone assumes the poker hands form on adjacent hexes. They do not. Getting that wrong would have welded the rules to the geometry forever.
Hex Poker TD is a tower defense where poker hands build the towers. Tell an engineer that and watch them reach for the obvious conclusion: the cards must combine when they are next to each other on the board. Adjacent hexes, a flood fill, a hand detected in the grid. It is such a natural guess that I have had it explained back to me as though it were my own design.
It is wrong, and the wrongness is load-bearing. You select up to five cards from anywhere on the planet. There is no neighbour check. The scorer takes whatever you picked and runs plain, ordinary poker classification on it — ranks and suits, nothing spatial. Hex adjacency exists in the game, but it is used for enemy pathing and for asking what is near a wall. It never once decides whether a hand is a hand.
That separation is the most valuable line in the codebase, and I did not appreciate it until I tried to move the board. The rules layer owns one hundred percent of the poker logic and knows nothing about geometry. The board is a small interface — where are the cell centres, who are a cell's neighbours, is this one of the pentagons, find me a path. A sphere satisfies that interface. So does a flat hex grid. Both exist, both are real, and the poker mechanic runs unmodified on either, because it never asks what shape it is standing on.
Had I taken the obvious route and defined hands as adjacency patterns, the rules and the geometry would have fused. Every change to the board would have become a change to poker. The flat grid would have needed its own hand detector. Adding the twelve pentagons would have meant deciding what a straight means when a cell has five neighbours instead of six — a question with no good answer, invented entirely by a design mistake.
The scoring hides a small piece of arithmetic I am fond of. Straights are the annoying hand in every poker implementation, because the Ace is both high and low and the naive fix is a special case bolted on afterwards. Instead, map the thirteen ranks onto a cycle and ask a single question: of the four gaps between five sorted cards, is every one of them a step of one? On a cycle, the Ace-low wheel satisfies that with no special pleading — and so does every wrap-around run that a linear check would have missed. The Ace stops being an exception because the number line stopped having ends.
The lesson generalizes past card games. When you are choosing what a rule depends on, prefer the smallest thing that makes it true. Poker hands depend on ranks and suits. They do not depend on where the cards are sitting — and the moment I let them, I would have owned that dependency forever.
- 01Hex Poker TD — play it in your browser
Select five cards from anywhere. The hand does not care where they were.
/games/hexpoker
- 02Functional core, thin bridge
The same seam, found in a different codebase: rules in the middle, everything else at the edge.
/blog/functional-core-thin-bridge
- 03