In our previous articles, we explored how the Minimax algorithm helps computers make decisions in games like Tic-Tac-Toe. But there's a big problem: checking every possible move can take a very long time in complex games!
Even simple games create huge game tree:
No computer could possibly check every move in complex games like chess or Go. That's why we need smarter approaches.
Let's see how computers overcome this challenge.
In games too complex to search to the end, computers use evaluation functions to estimate how good a position is.
For example, a simple tic-tac-toe evaluation might count:
In chess, evaluation functions consider many factors:
Deep Blue, the computer that defeated world chess champion Garry Kasparov in 1997, used an evaluation function with approximately 6,000 different factors!
Imagine you're deciding which movie to watch by reading reviews. If the first three reviews for Movie A are terrible, would you need to read all 100 reviews before deciding not to watch it? Probably not!
This is the idea behind Alpha-Beta Pruning. It's a technique that helps computers skip checking branches of the game tree that won't affect the final decision.
Let's understand this with a simple example:
Alpha-Beta Pruning can dramatically reduce the number of positions a computer needs to check:
This means computers can look much deeper into the game tree and make better decisions in the same amount of time!
Even with Alpha-Beta Pruning, games like chess are too complex to explore all the way to the end. To handle this, computers use:
What about games with random elements, like backgammon with dice rolls?
For these games, computers use an algorithm called expectiminimax which:
This allows computers to make optimal decisions even in games where luck plays a role.
The techniques we've discussed have helped computers master many games. However, the journey of game-playing AI shows how far adversarial search has come:
Next time you play a game against a computer—whether it's tic-tac-toe, chess, or a video game—you'll know a bit more about the adversarial search algorithms working behind the scenes, calculating the moves most likely to defeat you!
Challenge: Can you beat an unbeatable AI? Try playing against one online and see if you can force a draw! Remember, with perfect play from both sides, Tic-Tac-Toe always ends in a draw.