4D Tic Tac Toe
July 2026
In my first class of Linear Algebra, My professor showed us how Tic Tac Toe worked in 3 dimensions, forced us to play a game, then explained how it could even extend to 4D and how he played 4D tic tac toe with his friends during lectures when he was a student.
I was very intrigued, so I decided to try to make it so I could play with friends online! I also created a computer player to play against, and they are pretty tough to beat! A little fun fact, at 5x5x5x5 the game is actually unsolved, and there are a bit less than 625! possible games.
you can try yourself here.
The premise is its 4D by being represented with a 2d grid of 2d boards.
the way displayed the 4 dimensions are on a 5x5x5x5 board:
- x: going left/right on the same small 5x5 board
- y: going up/down on the same small 5x5 board
- z: going left/right on the big grid of 5x5 boards, while remaining on the same square in the small 5x5 board
- w: going up/down on the big grid of 5x5 boards, while remaining on the same square in the small 5x5 board
and the direction of the line would be 1,0, or -1 in each dimension
if you can make a line of 5 with each step going the same direction, you win!
Here are some examples. Its hard to wrap your head around at first.

Winning in w direction (all 5x5 boards in the column are marked at the same spot)

Winning in y and z direction (when z goes right, y goes up)

Winning in x, y, and z direction (when z goes right, x and y go left and down)
At first I challenged myself to complete this project over one weekend and I ended up finishing most of it by the end of sunday, so I’m quite proud I was able to turn an idea into reality so quick! I more recently turned it into a website and added new things to it.
4D old box pushing game except you need to line up the boxes + 4D!!!
During finals of the same semester, I also decided to try and to make a single player puzzle game using this same idea, where you need to line up some boxes, similar to sokoban
Check it out here! it might help you understand 4D tic tac toe better.
