CMU Artificial Intelligence Repository
TIC-TAC-TOE: A Prolog implementation of Noughts and Crosses
lang/prolog/code/fun/ttt/
This program was written by David Green as an MSc exercise when he was
at Edinburgh University in 1991.
The most interesting thing about it is its use of a 3x3 'magic square'
to represent the playing area. This means that each position on the
noughts & crosses board is given a numerical value:
8 3 4
1 5 9
6 7 2
It is a property of this magic square that each winning line in noughts
& crosses has a total sum of 15. Thereore, 15 as a sum of three numbers
uniquely defines a particular winning position of the game. The game
state is stored as a list of the numbers which have been 'taken' so far
by the user, a list of the numbers which have similarly been taken by
the computer, and finally a list representing the current board state,
in which positions which have previously been filled by either player
are marked with an 'o' or an 'x' as is appropriate. Furthermore, this
representation makes it possible to refer to any vacant board position
by a single number from 1 to 9.
Origin:
src.doc.ic.ac.uk:packages/prolog-pd-software/ (146.169.2.1)
as noughts_and_crosses.zip
Version: FEB-91
Ports: Sicstus Prolog
CD-ROM: Prime Time Freeware for AI, Issue 1-1
Author(s): David Green
Edinburgh University
Keywords:
Authors!Green, Edinburgh, Prolog!Code, Prolog!Fun Programs,
Tic-Tac-Toe
References: ?
Last Web update on Mon Feb 13 10:33:42 1995
AI.Repository@cs.cmu.edu