Time for action – winning is everything

To determine the best course of action for the computer opponent, we need to create a prioritized list of rules for the computer to follow when deciding how to place a piece, which changes depending on the situation on the board. Let's pretend we are the computer, and we see this situation:

Time for action – winning is everything

It wouldn't make sense to place an O anywhere but in X's way—otherwise, the computer loses. So we have our first rule:

  • Block opponent from winning

Now let's look at this situation:

Time for action – winning is everything

Sure, X is about to win, but O also has an opportunity ...

Get Unity 4.x Game Development by Example Beginner's Guide 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.