How it works...

We define a new type of move for the board that works well with the base algorithms because they make use of it only at a high level as a data structure. The recipe's bread and butter comes from overriding the virtual functions from the Board class to model the problem. We use a two-dimensional integer array for storing the players' moves on the board (0 representing an empty place), and we work out a heuristic for defining the value of a given state regarding its neighbors.

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.