Gin and Rummy AI – Post Mortem


Well, the Gin and Rummy AI I’ve been posting on and off about for the past month is complete – and I’m pretty satisfied with how it did.


So my class held a double elimination tournament where we pitched our AI’s against each other in an ultimate showdown to decide the best Gin Rummy AI.¬† My AI got 7th place, so taking into account that there were 13 entrants, my AI got about halfway through. It definitely did better than before, and I think that’s because of a quick algorithm change I made.

Last Minute Changes:

In my initial valuing algorithm, the card with the highest assigned value is discarded. Any cards that were part of a set or run got a value of 1. Cards partly making a set or run got a value of 2. Garbage cards got a value of 3 + card value. The key issue with this system is that later into the game, my AI would sometimes hang on to several high valued cards that it would refuse to get rid of because it was “almooooost” there. The result was sometimes holding 2 kings, and 2 jacks, and then handing over 40 points to my opponent that I could’ve saved myself from. In order to alleviate this, I added an extra condition. If the deck is more than halfway spent (meaning someone is probably gonna knock soon), I begin adding the card value to the cards that make part of a set. The result meant that my AI would dispose of cards that are dangerous if too much time has passed.

This was a great change, my AI ended up playing a lot safer and gave out a lot less points to my opponent whenever luck wasn’t on its side.

In an Ideal World:

If I could add another thing to my AI it would be the ability to count cards. If my AI kept track of what cards have been discarded or picked up, I could use that data to modify my valuing system. This would mean that if a card is part of a set or run that I know would be harder to get because a certain card has been discarded – I can rate that card much higher than its fair game counterparts.

Card counting would also help with ensuring that my opponent doesn’t get a card that could help them. If the card I’m about to discard could possibly help with a set or run that my opponent is foreshadowing at with a card they just drew from the discard pile, I could simply hold on to that card for a while and discard something else.


I was pretty satisfied with my AI but it would’ve been nice to get in the top 3. I honestly believe that the card counting strategies I mentioned above is really what my AI was missing in order to outshine the rest. Regardless, I’m glad with the last minute change I made, and I like to think that if this AI were to be put in a game – it’d be fun to play against!

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s