A tictactoe where you never win, implemented using minimax algorithm


Make sure you have the pygame module along with Python. If not, use the package manager pip to install.

pip install pygame


It is a two-player game between the user and the computer. The computer is made ‘smart’ using the minimax algorithm. This algorithm minimizes the chance of the user to win while simultaneously maximizing the chance of the computer to win. Hence the computer never loses no matter how hard the user tries.

*In the home-screen the user is free to chose either X or O

*The user can play the game any nummber of times using the re-play feature

*Each game ends in a draw or the computer wins

*User gets the first chance always

How to run

Copy the repo to your local device and simply execute the python file

python tictactoe.py


  1. Home Screen


  1. Game Board


  1. Winner Screen



Jessica Jolly UwU

I’m just a beginner in programming, so I know there are better ways to implement some of these features. If you know an easier and more efficient way to do so, do let me know!


View Github