Newsgroups: comp.ai.games
Path: cantaloupe.srv.cs.cmu.edu!rochester!udel!news.mathworks.com!news.kei.com!wang!news
From: bruck@actcom.co.il (Uri Bruck)
Subject: Re: Tic Tac Toe - Noughts and Crosses
Organization: ACTCOM - Internet Services in Israel
Date: Tue, 11 Apr 1995 22:04:50 GMT
Message-ID: <D6w5C3.G0v@actcom.co.il>
References: <3m12op$sss@monterosa.zurich.ibm.com>
Sender: news@wang.com
Lines: 56

Andre-John MAS (aj_mas@be.ibm.com) wrote:
:   Tic Tac Toe - Noughts and Crosses, whatever you call it.  I want learn
:  about AI and knowledge programming and would therefore be interested
:  in any code and algorithms that will allow me to understand the
:  techniques.  As 0s and Xs is a relativly straight foward game, with
:  a small number of combinations, I would be interested in code / algorithms
:  that would show AI being applied to this game.

:  Please Email me

:  Thanks

:  Andre-JOhn

Here is an approach I once tried, and it seemed to work.
imagine for a moment a different game. in this game you have no matrix
to fill, just the numbers 1-9. each player in picks a number in turn and adds
that number to his/her list and crosses it off the initial list.
the first player that can create the sum of 15 with exactly three of his 
numbers wins the game (note:this is not TTT with numbers, that is a 
different game, which was described in the Journal of recreational 
Mathematics, if anyone is interested I can give the refference, currently not
on hand, or describe it , in a seperate post)
 the game I described above is exactly analogous to tic-tac-toe. How
is that? consider a magic square.

8 1 6
3 5 7
4 9 2
each row, column and diagonal sums up to 15. no other triplet of these
digits sums up to 15.the game as described above is simple to program
and the magic square maps it onto the tic-tac-toe matrix, simultanesouly
taking care of the various symetries.

general algorithms:
if first move, pick the center - select 5
otherwise, test for human win (assuming computer plays human) 
	if true- declare human the winner
 [defensive]
else, test for oponent pair, i.e. win on next move -
	add up all possible pairs of oponents numbers, and see if any can 
be completed to 15 on next move, if so block by slecting the number
that would complete to 15.
 [offensive]
otherwise, test whether you(algorithm) can win this move (you might like
to swap these two steps), by adding up all pairs of your number list
and completing the sum appropriaely
if no such pair exists - try to create one, test each of the reaminig
unpicked numbers with your numbers list for the numbers of pairs it can
make that can completed to a winning trio on the following move.
pick the highest number (the highest could only be 2)

apologies for the spelling, it's 1 a.m. over here, this algorithm wins 
whenever it gets the first move.
		Uri Bruck
		bruck@actcom.co.il
