Artificial Intelligence In Games - All Fours
Games that Think
The field of Artificial Intelligence is one that has been growing in prominence in recent years. The introduction of smart assistants such as iPhone's Siri, Microsoft's Cortana and Amazon's Alexa has pushed artificial intelligence into the limelight. Artificial intelligence has been around for a long time though, especially in video games where it has provided a challenge against even world champion chess players such as Garry Kasparov. Many games feature artificially intelligent agents that vary from the simple enemies which follow players around in Super Mario Bros to the lifelike behavior of opponents in modern first-person shooters such as Call Of Duty. GamePyong has also used AI for some of its games in order to provide a compelling single-player experience. The post will feature one of the more interesting examples of video game AI written for the card game All Fours.
Single-player All Fours
In our previous post about the game of All Fours, we mentioned that it's a four-player card game in which you two teams of two players compete against each other. GamePyong's first version of All Fours was a multiplayer game which can be played against real players online. Sometimes though, you might not want to play online or you might not have access to the internet. For situations like those, we developed an offline version of All Fours which does not require internet connectivity and can be played anywhere at anytime. This version features an AI opponent and partner to fill in for the other three players.
The Brains of the Operation
In order to produce a challenging opponent for the player, we fully utilized the strengths that the artificial agent possesses. A computer can perform millions of calculations per second. The goal of the AI is to decide which card is the best card to play at the current point in the game. The AI is able to use the information that is available to it such as what cards have already been played, what card are in its hand and its partner's hand and what cards might be in the player's hand. All of this information is used to build a simulation of what the possible outcomes might be if the AI plays a particular card. The simulation tries every possible combination of cards in the artificial agent's hand with the goal of finding the card that maximizes its score at the end of the game. Millions of these simulations are run during the opponent's turn before it selects a card to play. The AI is constrained by the rules of All Fours, so it cannot play an invalid card and it will try its very best to save or hang jacks and try to win the point for gamble. Your partner's AI also goes through the same process in order to select the best card to play. The game allows you to either tell your partner what to play or allow it to play for itself.
You can try your hand against the AI here: Play All Fours