Gin Rummy
Buh bye Minesweeper, hello Gin Rummy! Quick note: Gin Rummy is different from Rummy 500. I didn’t discover that for a stupidly long amount of time. Our next game to create an AI for is Gin Rummy, a card game that was originally created for faster-play poker. The game consists of creating melds of 3-of-a-kind or runs of at least three length. The cards in your hand that don’t actively create these melds are known as deadwood, and accrue points based on their number (with faces being worth 10 and aces being worth 1). If a hand has less than 10 deadwood, that player can ‘knock,’ which ends the round. At this point, the player with the less deadwood wins: if it’s the player that knocks, they get awarded points based on the different in deadwood. If the other player wins, they get a 25 point undercut bonus in addition to the deadwood difference. If a player has no deadwood, he has gin, which is an automatic win and a 25 point bonus. There’s also the concept of ‘laying off’ cards, but we aren’t worrying about that with our project.
Before I show my hand (haha… get it?) and explain how I plan to tackle this project, let me put down all of the incredible and detailed sources I have stumbled upon. All of the info I will be referencing is from these sources.
There are three banks of info in Gin Rummy: the discard pile, which is information perfect, the deck, which is imperfect, and the other players hand and draws, which are also imperfect. As such, the game is up to a lot of probability and some games are simply un-winnable against a competent AI. Regardless, there is much we can do to be as efficient as possible.
If drawing first, take the discard card rather than one from the deck. You’re letting your opponent farm this information from you, but it prevents him/her from taking it, and gives you the upper edge in two regards: if they DID need it, they will discard the cards that will work towards a meld, and if they DIDN’T you can safely discard it and throw off their AI’s interpretation of what you are trying to do. Early in the game, unless given a plethora of face cards, it is a good idea to hold onto them for a turn or two to see what your opponent discards - it may very well be face cards. When discarding in the beginning, it is better to discard a card with a ranking one or two away and in a different suit to the one previously discarded by your opponent, e.g. if your opponent discarded a 6 of diamonds, discard a 7 or 8 of clubs/hearts/spades. This will statistically give you the best chance of discarding a ‘safe’ card: one your opponent can’t use. If this can’t be done, discard a rank equal to the one that your opponent has previously discarded: there are only two others left in the deck, lowering your chances of forming a kind-meld. Speaking of which, there are 52 kind melds and 44 run melds, which might make it seem like it makes more sense to go after kind melds, whereas the opposite is true: sequence melds can be more than 4 cards, and they can usually be extensible in both directions. As such, 7s are the most valuable cards if playing that strategy.
Gin Rummy is a game about knocking as quickly as possible: outright going for gin is statistically foolish. Thus, it is important to calculate deadwood limiting and card spreads, or triangles. Since we don’t have to worry about layoff, there’s not much of a chance of an undercut occurring. Spreads are the concept of having high meld probabilities: one-gaps, two-sequences, and shared kind-runs are all examples of these.This image shows bad combinations at the top, and progressively better combinations at the bottom. This source specifically explains the idea of ‘upcards’ and spreads.
In the end, my AI will be more or less an information hog. It will read every discard, every pickup, and how many cards are left in the deck to statistically discard the safest card each turn, while forming spreads and triangles and keeping its deadwood low.
Did I mention we’re doing bracket-style elimination for this competition? Color me excited.