[Community Puzzle] Tic Tac Toe Engine - Puzzle discussion

Coding Games and Programming Challenges to Code Better

Send your feedback or ask for help here!

Created by @User123,validated by @N3l,@Anonimee and @kozuechan.
If you have any issues, feel free to ping them.

This is a great puzzle. Thank you so much for contributing it.

I am having problems to understand the decision logic. Let’s take the example “Hold the Draw” from the examples provided:

O
.O.
..X
.X.

I have calculated, for each possible move of O, how many paths will lead to (a) O winning, (b) X winning, (c) tie. I get these three statistics for each possible move of O.

I define chance_of_O_winning = numer_of_paths_O_wins / (paths_X_wins + paths_O_wins)

By doing so, the center tile has the biggest chance of O winning. This follows the common sense logic of “grab the middle if you can”.

The solution suggest that O places in the top left corner. The example name (“Hold Draw”) suggests that the logic chooses this path, since it maximizes how long I can delay a draw.

I am having difficulty to understand what “delaying the draw” seems to have been the deciding logic; and not “maximizing chances of O winning” (which would be given by the middle field).

Thanks

Hi @Banta2000 ,

If you play the center tile, and I play the tile at the bottom right:

.O.
.OX
.XX

I’m sure to win the game ^^

@GFabian thank you so much!! This absolutely solved the mystery for me.

As a matter of fact, I assumed that the opponent would play all possible moves - and then I would compute the win / loss statistics. In fact, the opponent plays always optimal turns. Meaning, the opponent will not permutate through all possible moves, but rather only choose moves that will either force a win or a tie for the opponent.

This allowed me to solve the puzzle.

Thanks a lot.