Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

TIC-TAC-TOE Code

Status
Not open for further replies.

todor81

Programmer
Dec 14, 2001
5
BG
Hi, there
can anybody send me a strategy or code for a tic-tac-toe game or tell sites where I can found information about it.
 
well, the approach i would take is using a 3x3 array

int array[3][3];

then determine if you want x's or o's to go first. Display the contents of the array in ascii on the screen and ask them where to put their mark

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


write an algorithm to make the computer think by weighing each open spot and chances that it could win if it placed a mark in the spot. Basicly determine the possible lines you could draw to win.

Also, look at the oponent and determine if they can win next move and place a blocking mark in their path.

That would be the gist of how I would go about designing this.

Matt
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top