Just follow the usual steps when you play tictactoe.
Just follow the usual steps when you play tictactoe.
Devoted my life to programming...
I know that, I just don't know how to link my steps with each other in a code...
I was thinking of making a counter-defense way of thinking for the AI - analyze horizontally, diagonally and vertically if there are two of the player's marks ('x'/'o') and put a counter-move to that ('o'/'x') but if there are none - play offensively. But I think that would also require lots of ifs and loops (the defensive part). I would also have to take into account the tricky moves where you put the opponent in a "fork" where I have two places to put my mark that are a winning situation. Something like this:
(ugh, spaces seem to be ignored so I put _ instead
-------------
| x | _ | x |
| _ | o | _ |
| x | _ | o |
-------------