How it works...

Since we know the basic principle of the algorithm, let's concentrate on the search strategy. There are two values: alpha and beta, respectively. The alpha value is the lowest score a player can achieve, thus avoiding considering any move where the opponent has the opportunity to lessen it. Similarly, the beta value is the upper limit, and no matter how tempting the new option is, the algorithm assumes that the opponent won't provide the opportunity to take it.

Given the alternation between each player (minimizing and maximizing), only one value needs to be checked at each step.

Get Unity 2018 Artificial Intelligence Cookbook - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.