Solved

# play the computer in Tic Tac Toe

Posted on 2003-03-11
Medium Priority
293 Views
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.
0
Question by:alxnder
[X]
###### Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

• Help others & share knowledge
• Earn cash & points
• Learn & ask questions

LVL 6

Expert Comment

ID: 8112831
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

Author Comment

ID: 8114796
I got it to check winner but how do I make the computer play?
0

LVL 6

Accepted Solution

gj62 earned 105 total points
ID: 8114855
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

LVL 7

Expert Comment

ID: 8116626
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

LVL 20

Expert Comment

ID: 10121044
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

## Featured Post

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Summary: This tutorial covers some basics of pointer, pointer arithmetic and function pointer. What is a pointer: A pointer is a variable which holds an address. This address might be address of another variable/address of devices/address of fu…
Windows programmers of the C/C++ variety, how many of you realise that since Window 9x Microsoft has been lying to you about what constitutes Unicode (http://en.wikipedia.org/wiki/Unicode)? They will have you believe that Unicode requires you to use…
The goal of this video is to provide viewers with basic examples to understand how to create, access, and change arrays in the C programming language.
The goal of this video is to provide viewers with basic examples to understand and use conditional statements in the C programming language.
###### Suggested Courses
Course of the Month12 days, 20 hours left to enroll

#### 777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.