Tic tac toe solver

  • Category: Script, Mathematics
  • Project date: July, 2024
  • Project URL: A zip file containing the whole of the project is downloadable here

Description

Python exhaustive solution of the tic-tac-toe game. It consists on a python notebook where all the possible tic-tac-toe games are computed and studied. This project (motivated by the graph theory course on the math degree), aimed to provide a winning strategy for any immaginable board of the game

The game was given a mathematical structure and the resulting computation was not particularly expensive. The problem resided on the visualization of the results, since the final graph had close to 1M nodes. I decided to do an alternative representation with images, each representing the tree of possible games that resulted after any first two movements.

The study could have been furtherly optimised by considering the simmetries within the board and the games. Another option could have been to compute the possible games starting from all possible final boards and going up (probably decreasing notably the computation time).

Long story short, it is best to start on the center or on a corner, but if the other player plays optimally all we can aspire to is drawing the game.