Square Tic Tac Toe

In this project, you'll create a game GUI as well as see how you can program an Artificial Intelligence (AI) that makes smart moves. While tkinter is not typically suited for creating game GUIs, this project is simple enough to manage with basic widgets and layouts.

Tic Tac Toe (also known as noughts and crosses) is a popular choice for a beginner project. In this two player turn based game on a 3x3 board, the aim is to form a line with three consecutive cells in any direction — horizontal, vertical or diagonal.

To make it more interesting and challenging, you'll also extend the game to aim for a square on a 4x4 board. To begin with, the computer will make random moves. Later, you'll use a weight based algorithm to program a smarter game AI.

Project summary

  • Learn to use grid() layout
  • Create clickable Label with image background
  • Implement GUI for the Tic Tac Toe game
  • Make minimal changes to the Tic Tac Toe GUI so that the players have to form a square on a 4x4 board
  • Program a game AI using weight based algorithm

The following modules and concepts will be utilized in this project:

Real world influence

Square Tic Tac Toe holds a special place for me. I first came up with this tweak to the classic game in high school. For a competition in college, my friends and I implemented the game with multicolor LEDs. That was my first attempt at writing a game AI. A few more years later, I made an Android game out of this concept.

And now, I'm using it again as one of the projects for this ebook.