/* * file mr.c * a program to play the game mini-Renju ... */ /* INCLUDES */ #include #include #include "genlib.h" ... /* DEFINED CONSTANTS */ #define BoardSize 10 /* we'll use a 10x10 board */ #define MaxMoves 100 /* on which there are 100 cells */ ... /* NEW TYPE DEFINITIONS */ typedef enum {Black,White} player; /* two players - Black and White */ ... /* PRIVATE GLOBAL VARIABLES */ static bool done = FALSE; /* is the game over? */ static bool autoPrinting = FALSE; /* automatically print board? */ static player currentPlayer = Black; /* who plays next? */ static int nextMove = 0; /* number of the next move */ ... /* FUNCTION PROTOTYPES */ void printHello(); /* print initial welcome */ void printGoodBye(); /* say who won in how many moves */ void printPrompt(); /* print prompt showing who's to move */ void doCommand(char *cmd); /* process a command line */ void doQmark (); /* print list of commands */ void doHelp (); /* print more detailed help */ void doBoard (); /* (print|board) print the board */ void doMove (int i, int j); /* current player plays at (i,j) */ void doMoves (); /* print the move history */ void doUndo (); /* undo the last move */ void doResign (); /* current player resigns */ void doQuit (); /* quit - no winner */ void doAutoBoard (char * onOrOff);/* process the autoboard x command */ void doUnknown (char * cmd); /* complain about an unknow command */ void isWinningMove(int i, int j); /* was move i j a winning move */ ... /* THE MAIN FUNCTION */ void main { char cmdLine[128]; printHello(); while(!(done)) { printPrompt(); gets(cmdLine); doCommand(cmdLine); } printGoodBye(); } /* THE FUNCTION DEFINITIONS */ void printHello() { ... } ...