Lines 3-5: Globals should be avoided.
Line 9: You probably don't want to output this every time you draw the grid.
Lines 25-114: Do you see a lot of repeated code here? That's a good indication you need a loop and/or a function call.
Lines 129-146, 149-166: The only difference between these two groups of lines is which player is being checked. Again, This can be rewritten as a function, passing the player as an argument.
I am asking is how would I allow it to be played against the computer? |
That can be as simple or as complex as you like.
At the simple end of the spectrum, have the computer randomly take any empty cell.
At the more complex end of the spectrum, have the computer look for patterns. First check if the computer already has two in a row. If so, complete that row. If the computer doesn't have two in a row, see if the player has two in a row and block.