Share your repls and programming experiences

← Back to all posts
🤖 5x5 Tic Tac Toe Bot - Taking 3x3 to the next level!
DaBananaGuy (30)

Play a game of 5x5 Tic Tac Toe against a very hard bot! A true challenge compared to 3x3.


We are all used to playing 3x3 tic tac toe. A relatively easy game to tie, and a bit harder to pull off a win. This bot takes it to the next level!

You can now play 5x5 tic tac toe against a very good ai. This is a true challenge to win. If you win, comment below (you deserve a cookie).

How the AI Works

The Ai follows a set process:

1) Check if there is a space where either player can go to win immediately.
If so, go there. You are either blocking the enemy or winning the game.

2) Check if you can make a fork. That is a move that opens up multiple groups of five empty spaces. With forks, you will be able to attempt to win in different directions.

3) Play an open corner (4 spaces)

4) Play an open center space (9 spaces)

5) Play an empty side space (12 spaces)


A suggestion, you might want to put the number of the boxes in the box so you don't have to count which box is which. Otherwise it is pretty good!

DaBananaGuy (30)

@IEATPYTHON Thanks for the suggestion.

Grify (6)

Thats actually pretty cool, good job!

DaBananaGuy (30)

@Grify Thanks. I loved tic tac toe, and I wanted to make it a real challenge.

Steven_The_GuyT (197)

Nice game! I really like playing it. I think that you should put numbers in the boxes to signify which box is which number. Also, I drawed against the ai.

ssp4all (6)

For input greater than 24 program is crashing..better to add a try n catch
BTW very nice :)