Recursive TicTacToe

To get myself more used to thinking recursively, I wrote a recursive version of TicTacToe that can operate at an arbitrary depth. A normal game (depth 1) ends when one player makes three matching cells in a row. To make this recursive, the cells themselves are their own mini games of TicTacToe. They have the same win conditions, so you have to win three games in a row to win. To make it more interesting and strategic, the position that one player plays on determines the region that the next player can play on. For example, in a depth 2 game, if player X plays on the top left cell of any mini game, player O has to play in the top left mini game. This can repeat to any depth, so all of the program logic, including getting the cell position, changing the cell, checking for a winner, and rendering the game has to function recursively. Here is the Python code.

Depth 2
Depth 3