For a first draft you may want to ignore all other kinds of brackets, and assume there are no brackets placed inside text or comments. If you're feeling ambitious afterwards, see if you can adapt your solution to handle those cases too. (Research "matching brackets" if you don't know where to start.)
Next, replace one of the players with an AI opponent that plays optimally.
Finally, write a "Suicide Tic Tac Toe" game, where the objective is to force the other person to get three in a row. (First tackle the player-vs-player version, then work on an AI.)