Ultimate Tic-Tac-Toe

During the Fall 2020, Spring 2021 school year, Valparaiso University’s math club (of which I was vice president) worked on research into the tic-tac-toe variant ultimate-tic-tac-toe. I had already written a python program for basic command line gameplay, but I also wanted to write a faster implementation for potential deep learning research purposes. We did not end up with any super exciting results, but it was still a fun project to work on.

Source Code

The source code for this project is available on GitHub.

Demo

> python3 ultimatetictactoe.py
Player 1 name:   Eric
Player 2 name:   Player 2

It's Eric's turn!
The board looks like this:
 | | ▮ | | ▮ | |
-+-+-▮-+-+-▮-+-+-
 | | ▮ | | ▮ | |
-+-+-▮-+-+-▮-+-+-
 | | ▮ | | ▮ | |
▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬
 | | ▮ | | ▮ | |
-+-+-▮-+-+-▮-+-+-
 | | ▮ | | ▮ | |
-+-+-▮-+-+-▮-+-+-
 | | ▮ | | ▮ | |
▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬
 | | ▮ | | ▮ | |
-+-+-▮-+-+-▮-+-+-
 | | ▮ | | ▮ | |
-+-+-▮-+-+-▮-+-+-
 | | ▮ | | ▮ | |
You may go anywhere.
What move would you like to make?
(format moves like: (x,y)(x,y). The origin is the top left, so (1,1)(1,1) is the top left corner.
Your move:    (2,2)(1,1)

It's Player 2's turn!
The board looks like this:
 | | ▮ | | ▮ | |
-+-+-▮-+-+-▮-+-+-
 | | ▮ | | ▮ | |
-+-+-▮-+-+-▮-+-+-
 | | ▮ | | ▮ | |
▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬
 | | ▮X| | ▮ | |
-+-+-▮-+-+-▮-+-+-
 | | ▮ | | ▮ | |
-+-+-▮-+-+-▮-+-+-
 | | ▮ | | ▮ | |
▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬
 | | ▮ | | ▮ | |
-+-+-▮-+-+-▮-+-+-
 | | ▮ | | ▮ | |
-+-+-▮-+-+-▮-+-+-
 | | ▮ | | ▮ | |
You must go in grid number (1, 1).
What move would you like to make?
(format moves like: (x,y)(x,y). The origin is the top left, so (1,1)(1,1) is the top left corner.
Your move:    (1,1)(3,3)

It's Eric's turn!
The board looks like this:
 | | ▮ | | ▮ | |
-+-+-▮-+-+-▮-+-+-
 | | ▮ | | ▮ | |
-+-+-▮-+-+-▮-+-+-
 | |O▮ | | ▮ | |
▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬
 | | ▮X| | ▮ | |
-+-+-▮-+-+-▮-+-+-
 | | ▮ | | ▮ | |
-+-+-▮-+-+-▮-+-+-
 | | ▮ | | ▮ | |
▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬
 | | ▮ | | ▮ | |
-+-+-▮-+-+-▮-+-+-
 | | ▮ | | ▮ | |
-+-+-▮-+-+-▮-+-+-
 | | ▮ | | ▮ | |
You must go in grid number (3, 3).
What move would you like to make?
(format moves like: (x,y)(x,y). The origin is the top left, so (1,1)(1,1) is the top left corner.
Your move:    (3,3)(2,1)

It's Player 2's turn!
The board looks like this:
 | | ▮ | | ▮ | |
-+-+-▮-+-+-▮-+-+-
 | | ▮ | | ▮ | |
-+-+-▮-+-+-▮-+-+-
 | |O▮ | | ▮ | |
▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬
 | | ▮X| | ▮ | |
-+-+-▮-+-+-▮-+-+-
 | | ▮ | | ▮ | |
-+-+-▮-+-+-▮-+-+-
 | | ▮ | | ▮ | |
▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬
 | | ▮ | | ▮ | |
-+-+-▮-+-+-▮-+-+-
 | | ▮ | | ▮X| |
-+-+-▮-+-+-▮-+-+-
 | | ▮ | | ▮ | |
You must go in grid number (2, 1).
What move would you like to make?
(format moves like: (x,y)(x,y). The origin is the top left, so (1,1)(1,1) is the top left corner.
Your move:    (2,1)(2,2)

It's Eric's turn!
The board looks like this:
 | | ▮ | | ▮ | |
-+-+-▮-+-+-▮-+-+-
 | | ▮ | | ▮ | |
-+-+-▮-+-+-▮-+-+-
 | |O▮ | | ▮ | |
▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬
 | | ▮X| | ▮ | |
-+-+-▮-+-+-▮-+-+-
 |O| ▮ | | ▮ | |
-+-+-▮-+-+-▮-+-+-
 | | ▮ | | ▮ | |
▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬
 | | ▮ | | ▮ | |
-+-+-▮-+-+-▮-+-+-
 | | ▮ | | ▮X| |
-+-+-▮-+-+-▮-+-+-
 | | ▮ | | ▮ | |
You must go in grid number (2, 2).
What move would you like to make?
(format moves like: (x,y)(x,y). The origin is the top left, so (1,1)(1,1) is the top left corner.
Your move:    (2,2)(1,3)

It's Player 2's turn!
The board looks like this:
 | | ▮ | | ▮ | |
-+-+-▮-+-+-▮-+-+-
 | | ▮ | | ▮ | |
-+-+-▮-+-+-▮-+-+-
 | |O▮ | | ▮ | |
▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬
 | | ▮X| |X▮ | |
-+-+-▮-+-+-▮-+-+-
 |O| ▮ | | ▮ | |
-+-+-▮-+-+-▮-+-+-
 | | ▮ | | ▮ | |
▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬
 | | ▮ | | ▮ | |
-+-+-▮-+-+-▮-+-+-
 | | ▮ | | ▮X| |
-+-+-▮-+-+-▮-+-+-
 | | ▮ | | ▮ | |
You must go in grid number (1, 3).
What move would you like to make?
(format moves like: (x,y)(x,y). The origin is the top left, so (1,1)(1,1) is the top left corner.
Your move:    (1,3)(2,2)

It's Eric's turn!
The board looks like this:
 | | ▮ | | ▮ | |
-+-+-▮-+-+-▮-+-+-
 | | ▮ | | ▮ |O|
-+-+-▮-+-+-▮-+-+-
 | |O▮ | | ▮ | |
▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬
 | | ▮X| |X▮ | |
-+-+-▮-+-+-▮-+-+-
 |O| ▮ | | ▮ | |
-+-+-▮-+-+-▮-+-+-
 | | ▮ | | ▮ | |
▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬
 | | ▮ | | ▮ | |
-+-+-▮-+-+-▮-+-+-
 | | ▮ | | ▮X| |
-+-+-▮-+-+-▮-+-+-
 | | ▮ | | ▮ | |
You must go in grid number (2, 2).
What move would you like to make?
(format moves like: (x,y)(x,y). The origin is the top left, so (1,1)(1,1) is the top left corner.
Your move:    (2,2)(1,2)

It's Player 2's turn!
The board looks like this:
 | | ▮ | | ▮ | |
-+-+-▮-+-+-▮-+-+-
 | | ▮ | | ▮ |O|
-+-+-▮-+-+-▮-+-+-
 | |O▮ | | ▮ | |
▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬
 | | ▮X|X|X▮ | |
-+-+-▮-+-+-▮-+-+-
 |O| ▮X|X|X▮ | |
-+-+-▮-+-+-▮-+-+-
 | | ▮X|X|X▮ | |
▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬
 | | ▮ | | ▮ | |
-+-+-▮-+-+-▮-+-+-
 | | ▮ | | ▮X| |
-+-+-▮-+-+-▮-+-+-
 | | ▮ | | ▮ | |

Keywords: #python #python3 #game #mathematics #math

Eric Yager
Author: Eric Yager

Eric is a computer science & mathematics student and teaching assistant at Valparaiso University. He is also President of Valpo's student chapter of the Association for Computing Machinery (ACM) and Vice President of Valpo's Math Club. He likes to play chess (especially the bughouse variant), program in Go, and tent camp with friends.