CNoob2,
For availability, instead of comparing to 88 ('X') or 79 ('O'), perhaps instead compare to a default character and initialize your board to this default character. User input could then be changed to ask for both X row (0-2) and Y column (0-2). By the way, try to abstract the game characters to not always depend on 79 ('O'), etc. Maybe two const chars or other ways.
I see for display and user input, you're instead using some math to generate numbers 49 through 57 and then convert them to characters '1' through '9'. This makes the board not have a default character, but perhaps this is overthinking it a bit (comparison operators to int representations of characters make the intent a little vague at first glance). Less mathematical operations on the characters would make it all more readable and maintainable.
lines 85-91 it looks like AI tries to take a square whether it's available or not (pure RNG). You should instead search through the board and generate a list of pairs for open spots. Only then RNG on that if you want him to make a random yet available move. Once you have random move completely working and not accidentally grabbing unavail squares, you can look for smarter approach.
TicTacToe doesn't have too many possibilities, so you could do it as follows:
1. Search for immediate wins -- two of AI character in a row. Play in the first one found; return.
2. Search for immediate "about to lose" states -- two of Human character in a row. Play to prevent the first one found; return.
3. Now it gets trickier. An open middle on the AI's first move is safe, for sure, especially if the Human began the game. The AI's second move, if not obvious (#1 and #2), can be life or death. Suppose game went like this, Human 'X', AI 'O':
- - -
- - -
- - -
- - -
- - X
- - -
- - -
- O X
- - -
- - -
- O X
- X -
|
Now if the AI makes any of the moves [top-left, top-middle, middle-left] , he'll lose because he's not forcing human away from his plan of bottom-right.
4. Perhaps search for a forcing move (threatening a win) such that upon the forced human response, the human will not have two win threats. Return.
5. As last resort, lowest priority, make a random move from available moves.
gl.