Gin Rummy
Public domain classic
Match your cards into sets and runs, then knock before the computer does.
At a glance
- Rules
- Gin Rummy for two, you against the computer, 10 cards each, first to 100 points
- Melds
- Sets of three or four cards of one rank, and runs of three or more in one suit with the ace low only
- Knocking
- Allowed once the cards you keep leave 10 or less deadwood. Gin means none at all
- Controls
- Tap the stock or the discard pile to draw. Tap a card, then Discard or Knock, or drag the card onto the discard pile. Esc opens the menu
- Help
- Your best melds get green edges, a counter shows your deadwood, and Hint suggests where to draw from and what to throw
- Computer speed
- Steady waits about 0.65 seconds before each computer action, Fast about 0.3 and Relaxed about 1.1
- Saves
- Matches played, wins, hands and your best final margin over the computer, in this browser only
- Cost
- Free, no account
How this Gin Rummy plays
- Each player gets 10 cards and one more is turned face up to start the discard pile. You take the first turn of hand 1, and the first turn swaps sides every hand after that.
- On a turn you draw the top card of the stock or the top discard, then throw one card away. A card taken from the discard pile cannot be thrown straight back, but a card just drawn from the stock can.
- Unmatched cards are deadwood. An ace counts 1, number cards their face value, and jacks, queens and kings 10. The game works out the split of your cards into sets and runs that leaves the least deadwood, so a card that could join either a set or a run goes wherever it saves more.
- Knock: select the card to throw and press Knock. The button only lights up when the other 10 cards leave 10 or less deadwood. Reaching zero and pressing Discard instead does not end the hand: gin only counts when you knock.
- Lay-offs: after a knock, the other player adds unmatched cards to the knocker's melds, a fourth card to a set or a card at either end of a run, and one lay-off can open the way for the next. The knocker then scores the difference between the two deadwood totals.
- Undercut: if the defender's deadwood after lay-offs is equal to or lower than the knocker's, the defender scores instead: 10 plus the difference.
- Gin: scores 20 plus all of the other player's deadwood, and no lay-offs are allowed against it.
- When only two cards remain in the stock, or after 160 discards between you, the hand ends with no score and a new hand is dealt.
- The match ends as soon as a hand takes someone to 100. There are no extra bonuses for winning hands or the match.
How the computer plays
- Drawing: it takes the top discard only when that card would sit in one of its melds and lower its deadwood. Otherwise it draws blind from the stock.
- Throwing away: it throws the card that leaves the least deadwood. Between equal choices it prefers to drop a higher card, and to keep cards that sit near others of the same rank or the same suit.
- Knocking: it knocks the moment its deadwood is 10 or less. It never holds on to try for gin.
- There is no randomness and one level of play: the same cards always get the same choice. Hint runs the same thinking on your hand.
In the rule test the computer played 300 hands against itself. 277 ended in an ordinary knock, 17 in an undercut and 6 in gin, and none ran out of stock. Twenty full matches to 100 took between 5 and 15 hands.
Tips that follow from the rules
- Expect an early knock. The computer knocks on any deadwood from 10 down, so get rid of kings, queens and jacks you cannot use before they cost you 10 each.
- Its quick knocks give you undercut chances. If your melds can take its loose cards, or your own deadwood is already low, an undercut pays you 10 plus the gap.
- Read its pick-ups. When the computer takes your discard, that card has just gone into one of its melds, so think twice before throwing a card that would add to the same set or run.
- Watch the Knock button. Tap a card you plan to throw: if Knock lights up, the rest of your hand is already low enough to end the hand.
For a trick-taking game against three computer players, try Hearts.
Known limits
- No undo.
- No difficulty setting: the computer always plays the same way.
- Gin is never declared for you: with no deadwood left you still have to press Knock.
- On a 390 by 844 screen each card is 42 pixels wide and overlaps the next one, so tap near a card's left edge.
- In a 1280 by 720 browser window the game frame is 848 pixels tall, so your cards may sit below the window. Scroll down or press Fullscreen.
- Leaving the tab pauses the match behind the menu.
- With storage blocked, the match still plays but your totals are forgotten.
How it was built and checked
- AI tool
- Codex
- First committed
- 2026-10-15, in a batch of nine card games, built in the same run as Hearts and Spades
- Size
- One HTML file of 88 lines (about 33 KB), no game libraries
- Rounds of changes
- 1, from the build record
- Checked at build
- The build report: 172,629 rule checks for Gin Rummy, 300 complete simulated deals, 3 full computer matches, and a slowest computer move of 8.26 ms. It lists real appearance, touch and drag, keyboard focus, portrait and landscape layout and screen-reader output as not verified
- Checked since
- 2026-11-11: a new rule test for Gin Rummy alone (163,367 checks covering the deal, drawing and throwing rules, meld splits, lay-offs, knock, undercut and gin scores, dead hands, 300 random hands, 300 computer hands and 20 matches), the shared card test again (170,133 checks for Gin Rummy), and an automated browser check of the local build at 1280 by 720 and 390 by 844. Each time it drew from the stock, tapped a card and pressed Discard for four turns, saw a hand end and pressed Next hand, set your score to 99, knocked with gin to win the match, and started again
- Played on a phone
- 2026-11-11, a full game on a real phone before this page went live
Embed Gin Rummy on your site
Free to embed. Please keep the credit link.
<div style="position:relative;padding-top:75%;max-width:640px"><iframe src="https://aivibecodedgames.com/games/gin-rummy/" title="Gin Rummy (free browser game)" style="position:absolute;inset:0;width:100%;height:100%;border:0" loading="lazy" allow="fullscreen" allowfullscreen></iframe></div> <p><a href="https://aivibecodedgames.com/play/gin-rummy/">Play Gin Rummy free</a> on AI Vibe Coded Games</p>
How it was vibe coded
ToolCodex
Rounds of changes: 1
First committed2026-10-15
The opening prompt
Make Gin Rummy for two players against the computer. 10 cards each; on a turn draw from the stock or take the top discard, then discard one card. Melds are sets of 3 or 4 of the same rank, or runs of 3 or more in one suit (ace is low only). A player may knock when unmatched cards (deadwood) total 10 or less; gin means zero deadwood. After a knock the opponent can lay off cards onto the knocker's melds, and an undercut happens when the knocker's deadwood is not lower. Score the deadwood difference, plus 20 for gin and 10 for an undercut, and play to 100. Show the hand sorted with the best meld grouping and the deadwood total highlighted. The computer should take discards that complete melds, discard high unmatched cards, and knock when sensible. Add a hint button.
Game controls
- Tap the stock or the discard pile to draw
- Tap a card, then Discard
- Knock when your leftover cards total 10 or less
The game brief includes touch controls for phones.
Open the game on its ownMore games
PLAY
Klondike Solitaire
The solitaire everyone knows. Build four piles from ace to king.
PLAY
FreeCell
All 52 cards face up, four free cells, and numbered deals you can replay.
PLAY
Spider Solitaire
Build full runs from king to ace and clear the table.
PLAY
Hearts
Dodge the hearts and the queen of spades. Or shoot the moon.