The hardest task when creating a game is to come up with an algorithm for a computer opponent. Unless I am designing a game where you play against other humans, the only way a game will be considered enjoyable is if the computer opponent is smart. Finding an algorithm to make the computer appear smart can be quite challenging. Despite what you think if you’ve ever played one of the games, Blindfold Games computer opponents never cheat.
For card games like Blindfold Hearts, Blindfold Spades and Blindfold Rummy, I found computer science research papers that outlined the optimal strategy for a player. For example, the method used in Blindfold Rummy is even more complex than the game rules themselves. First the computer determines the number of complete groups (like 3 of a kind), and the number of complete runs (like Jack, Queen, King of Spades), then it determines the number of partial groups and runs, and computes the resultant deadwood for each hand combination (in Rummy, you try to minimize your deadwood). It keeps track of cards that are discarded, so it knows what may still be in the deck, or in the human player’s hand. Based on that information, it makes a pretty good decision about what to do.
The computer also determines the worst possible move – one that will generate the most amount of deadwood, and finally, it generates a random move. When it’s the computer’s turn, it will pick either the best move, the worst move or the random move.
To prevent the computer from always winning, I created 4 categories of players and assigned each a skill level, a Poor Player is rated as 10, Average is 20, Good is 30 and Very Good is 40. Then I generate a luck number to indicate how lucky the player’s next move is. For each move, the luck number is randomly picked, and is between 1 and 40.
For each move, I add those two numbers together. Hence the Poor Player’s combined luck plus skill number can be between 11 and 50, and the Very Good Player’s combined number will be between 41 and 80. If the combined number is greater than 45, the best move is picked. If the combined skill plus luck number is less than 30, the worst move is picked. If the combined number is between 30 and 45, the random move is picked.
Roughly speaking, the Poor Player will make a bad move about 90% of the time, and a good Player will make the optimal move about 90% of the time.
The next new feature I may add to the games is a ghost player. A ghost player has the same win-loss ratio that you do, so, in essence, you are playing against yourself. I’ll probably do that in Blindfold Bowling first, and then move it to some of the other games.