/* ECP: FILEname=fig7_18.c */ /* 1*/ enum Piece { Human, Computer, Empty }; /* 2*/ enum Side { You, Me }; /* 3*/ enum Color { X, O }; /* 4*/ enum Score { HumanWin, Draw, ComputerWin, Unclear }; /* 5*/ typedef enum Piece Piece; /* 6*/ typedef enum Side Side; /* 7*/ typedef enum Score Score; /* 8*/ typedef enum Color Color; /* 9*/ #define Bsize 3 /* 3 By 3 Tic Tac Toe */ /*10*/ typedef Piece BoardType[ Bsize ][ Bsize ]; /*11*/ /* Prototypes For Two Unwritten Routines */ /*12*/ void GetMove( BoardType B, Side S ); /*13*/ int IsWon( BoardType B, Side S ); /*14*/ /* Place Piece P ( Possibly Empty ) */ /*15*/ void /*16*/ Place( BoardType Board, int Row, int Column, Piece P ) /*17*/ { /*18*/ Board[ Row ][ Column ] = P; /*19*/ } /*20*/ int /*21*/ IsFull( BoardType Board ) /*22*/ { /*23*/ int Row, Column; /*24*/ for( Row = 0; Row < Bsize; Row++ ) /*25*/ for( Column = 0; Column < Bsize; Column++ ) /*26*/ if( Board[ Row ][ Column ] == Empty ) /*27*/ return 0; /*28*/ return 1; /*29*/ }