The project is to build on the tic tac toe program that we made earlier in the year. I made the first program (human vs human) no problem but now I've been asked to make an "AI" that will never lose against a human player. The computer must go first and start in the top left hand corner. It must play until it has won or there is a tie, losing is not an option. The program ran fine until I tried to make an "AI" function. Every time the program gets to this function instead of the computer placing an X in the appropriate spot it just forfeits it's turn and the human player is allowed to go again. Please help me figure out how to fix the "AI" portion of the code. I know the rest of the code is every inefficient but it works how I need it to. This is my first ever programming class I have taken and for some reason I choose to take it online, so I have every little knowledge when it comes to coding.
Tic tac toe is such a small game that you can compute every possibility for every move for the whole game each move and you pick the sequence of moves that has the less loses and the most wins and draws at the end of the game and you do that after each move