Monday, April 22, 2019

Tic Tac Toe "Trap"

I wrote my Tic Tac Toe tutorial  mostly for beginners: I thought that the game is simple enough for experienced players to know all the tricks in the book. It turns out that even expert players make mistakes.

Recently I googled "tic tac toe strategies". The very first search result came out as a coveted "featured snippet" and pointed to https://www.instructables.com/id/Winning-tic-tac-toe-strategies. The author of this page shows different fork configurations and classifies winning strategies for the first player (X-player) based on which fork configuration she should try to achieve. You might remember from my tutorial that a fork is a configuration in which a player can win on her next move by marking either one of two free squares. If a player creates a fork and her opponent does not have a way for an immediate win, he will obviously lose (if he blocks one winning square, she will win by marking the other). Here are some examples of forks created by X-player -- the two winning squares are highlighted in gray.




Back to the winning strategies recommended by the web page. "Strategy 1", as the author calls it, is a good one. It starts with a corner move and could really lead to a win if (of course) the second player (O-player) allows X-player to achieve the suggested fork configuration. But the so called "Strategies 3+4", are actually bad ones -- they could lose you a game. Let me explain.  I will follow the author's method of describing moves by numbering the squares of the 3x3 grid.  The author recommends taking squares 4 and 8 first, so that you can subsequently create one of two forks, as shown on the picture.



But the second player has a very effective counter strategy. If X-player starts with 4, O-player should respond with 1. Now if X-player takes 8 (as recommended by the author), she will fall right into a "trap" and deliver O-player an easy win!



Do you see why? I do not want to spoil the fun of finding the solution. But here is an answer, in case you want to compare your solution with mine. Obviously, X-player can avoid this "trap" by not blindly following "Strategies 3+4" on her second move. That is why I put "trap" in quotes.

Similar "traps" exist when X-player tries to setup a fork with different pairs of edge squares. Be careful when you play against the AI in my Tic Tac Toe app - it could "trap" you :-).

No comments:

Post a Comment