tic tac toe game

This is a discussion on tic tac toe game within the Game Programming forums, part of the General Programming Boards category; Ok, here is my new tic tac toe game. I re-wrote it because the old one had 100 more lines ...

tic tac toe game

Ok, here is my new tic tac toe game. I re-wrote it because the old one had 100 more lines than needed, all global variables, and less features.It has 3 difficulty levels. Here is the new one, please try it out and tell me what you think. It's under 300 lines of code.

PS. there was another guy that had a tic tac toe that kept score, thats where i got the score idea from.

1) When you ask if they want to play again, the person has to enter their name again... could get annoying.
2) I had a problem where after i chose to play again an infinite loop occured and the screen did nothing but flicker (ie, the grid was constantly being redisplayed). Looks like a buffer overflow issue to me (if the entered name is too long) as other wierd things happend too (like the game ending too early and stuff lke that).
3) You haven't put your name/credits in!

other than that mate.. you've done well.... is this one of your first projects??

nice stuff - anything with AI is good. i made my own T3 without the ai (i'm too lazy)

i'll suggest a few things to you to move to the next level of T3

1. warn the players while entering names about size,spaces etc
2. use ascii chars to make the grid
3. remove the numbers in the grid.. show a pre-game screen displaying the numbers or show it some othercorner of the screen
4. try use arrow keys to move, instead of numbers
5. use colours

1) On 'hard' I was able to beat the AI on my first try...granted this was primarily from doing a lot of playtesting on my own AI, but I'm sure others will be able to find this way to win too. The way to do it is like this:

1|2|3
4|5|6
7|8|9

Human goes first and chooses 7
Then the AI will choose 1
Next choose 3
AI will choose 5
You choose 9
AI will choose 8 or 6
You choose 8 or 6 (which ever one the AI didn't choose)

To stop the AI from loosing this way go like this:

H chooses 7
AI chooses 5

This will eliminate the possibiity of the human winning in this game

However, if this is the ONLY POSSIBLE WAY TO WIN then I would keep the AI how it is. You always have to make sure there is a way for the human to win, or else the game would be pointless.

I, too, like ihsir, find the numbers in the grid very annoying. The reason why in my game I went with row/col input instead of a single number input is because I think it makes the grid look a lot better. Although, if you do like ihsir suggest and put a small grid the upper right hand corner it would solve the problem.

For those that want do look at source code (hint hint Paveltc ) you can go here, but I'm not sure how easy the code is to read.