• C

play the computer in Tic Tac Toe

Player vs the computer. The trick is the computer is on the defense and I need to create a program that checks winner evertime it runs through each move. I have created the board and it can be played with two players but I am stuck. Please help.
alxnderAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

gj62Commented:
Sounds like homework.

We can't just give you the answer if it is homework - take your best shot, post your source, and indicate where you are stuck...
0
alxnderAuthor Commented:
I got it to check winner but how do I make the computer play?
0
gj62Commented:
Smartly?

If first, always go in center.  
If not, go in center if open.  
If not, go in diagonal... etc.

Always check for a block, or try to make 2 in a row - that's off the top of my head - it really shouldn't be that hard - you can map all unique permutations quite quickly...
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
MrNedCommented:
For general purpose turn based game playing like this, search for min-max algorithm. Used for eg in games like chess, checkers, othello and can certainly be used very simply in tictactoe.
0
jmcgOwnerCommented:
Nothing has happened on this question in more than 10 months. It's time for cleanup!

My recommendation, which I will post in the Cleanup topic area, is to
accept answer by gj62 [grade B] (homework).

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

jmcg
EE Cleanup Volunteer
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C

From novice to tech pro — start learning today.