I’ve seen tictactoes built with a math formula called minimax that makes the computer unbeatable. I didn’t add this into my tictactoe because I don’t like never getting a chance to win. Instead I make the computer choose a target randomly, and most of the time I win, but sometimes the computer wins and I like this more, but I would like the computer to have a higher chance of winning against me than the low chance that it currently has, not impossible to beat though like the minimax algorithm can make it.

Does anyone know a math formula I can use to achieve this? Or are there any tic tac toe games similar to what I’m describing that I can look into the code that made it like that?