Sunday, September 25, 2016

Gin Rummy Planning Post

For this assignment we have to make an AI to play gin rummy. Since I have never played gin rummy, I had to look at tutorials. I have however played rummy and rummy 500 before so I knew the basics of these types of card games. 

The AI will use a vector to keep track of all the cards in the discard pile. It will mostly pick up from the deck, it will only pick up from the discard if that card completes a run/set or adds to a completed run/set. In gin rummy games, picking up from the discard pile is not advised because it tells the other player more cards in your hand. So instead of having ten unknown cards you only have nine. Using this knowledge, your opponent can make educated guesses on what cards you are looking for or what cards you hold and alter the cards that he or she will discard. Since I don't know if other peoples AIs will using this knowledge to their benefit. My AI will only be picking up cards that are guarantee to help.

Since my AI is keeping track of the discard pile it can make educated decisions with what card to discard.  Since a game of gin rummy can end at any time, it would be wise to keep the lowest score in your hand at all times. So it will discard the highest valued, useless card. An example would be my hand is [King of hearts, King of diamonds, Jack of spades, 10 of diamonds, 5 of hearts, 4 of spades, 4 of hearts, 2 of spades, 2 of clubs, 2 of diamonds]. Providing that there is no kings in the discard pile, my highest values useless card is the jack, then the 10. If the discard piles has 6 of hearts and a 3 of hearts it will discard the 5 of hearts if it is the highest useless card. Then if the total number of deadwood in my hand is less than 10, the AI will knock ending the game.