Cribbage Online
Game Overview
Classic Cribbage online. Play against an AI opponent on a clean wooden board.
About Cribbage Online
Cribbage is a card game from 1630s England, supposedly invented by the poet Sir John Suckling, and it has barely changed in nearly four hundred years. Two players race to 121 points, scoring by laying down cards that make fifteens, runs, pairs and a few other patterns. Points are kept on a peg board because the scoring during a hand happens too fast for paper. If you grew up playing cards with your grandparents, you probably played a hand of cribbage at some point.
The game has two phases. First, you and your opponent each get six cards, keep four, and toss two into the "crib", a four-card pile that belongs to the dealer at the end of the hand. Then you play those four cards back and forth, picking up small points for hitting 15 or 31, runs and pairs as you go. After that you count up your hand for points, and the dealer counts the crib. Whoever passes 121 wins.
Our version puts you up against an AI that really knows the game. Deciding what to discard to the crib is the most important strategic moment in cribbage. You want to keep cards that work together in your hand without handing the dealer two cards that combine for points in his crib. Each turn the AI looks at roughly a dozen candidate discards and scores each one by expected hand value and expected crib damage. It isn't perfect. In some end-game positions it makes a slightly defensive choice that costs it a point or two. But it plays well enough that if you beat it consistently, you really do know what you're doing.
New to cribbage? The easiest way to learn is to play a few hands and let the scoring teach you. Pairs are worth 2 (three of a kind is 6, four of a kind is 12). Runs of three or more are worth one point per card. Any combination that adds up to 15 is worth 2. A flush in your hand is worth 4, or 5 if the starter card matches the suit. And the rare "his nobs", a Jack matching the suit of the starter card, is worth 1.
A few build notes. The peg board is drawn on a canvas, with each peg as a small ellipse with a slight shadow. We kept the wood texture and the green felt look on purpose, because cribbage is one of those games where the table matters. The hand-scoring logic was the trickiest single function I have ever written. There are roughly twenty distinct scoring patterns, and several of them interact in ways that aren't obvious. The unit tests for that function are longer than the function itself.
Frequently Asked Questions
What's worth more, 'fifteen' or a pair?
Both are 2 points. Runs of three are 3 points, and you score points individually for each scoring combination, so three 5s and a 10 is six fifteens (12) plus a pair royal (6), which is 18.
What's the highest-scoring hand?
29 points: four 5s and a jack of the same suit as the cut card. It happens roughly once in 200,000 hands, so don't hold your breath.
Does the AI cheat?
No, both sides are dealt from the same shuffled deck and the AI only sees its own cards and the cut card, exactly like you do.
What does 'his heels' / 'his nobs' mean?
His heels: if the cut card is a Jack, the dealer scores 2 immediately. His nobs: if you hold the Jack of the same suit as the cut card, you score 1 when counting your hand.