// Michael J. Fischer // CPSC 223b, Spring 2008 // Problem set 6: Hex game with undo/redo // This is a skeleton model for the Hex game. // It keeps the state of the Hex game, board position and turn, // and stub functions playGame(), undoGame(), and redoGame() // for the game logic. #include #include #include #include #include "util.h" #include "hexboard.h" #include "game.h" // ------------------------------------------------------------------------ // Private structure definition // ------------------------------------------------------------------------ struct game { Hexboard brd; int turn; }; // ------------------------------------------------------------------------ // Public functions // ------------------------------------------------------------------------ Game newGame( Hexboard hb ) { Game gm = safe_malloc( sizeof(*gm) ); gm->brd = hb; gm->turn=1; // Red plays first return gm; } // ------------------------------------------------------------------------ void freeGame( Game gm ) { free( gm ); } // ------------------------------------------------------------------------ Hexboard getHexboardGame( Game gm ) { return gm->brd; } // ------------------------------------------------------------------------ bool playGame(Game gm, double x, double y) { bool ret=false; // true means board changed printf("playGame called on point (%g, %g)\n", x, y); return ret; } // ------------------------------------------------------------------------ bool undoGame(Game gm ) { bool ret=false; // true means board changed printf( "undoGame called\n" ); return ret; } // ------------------------------------------------------------------------ bool redoGame(Game gm ) { bool ret=false; // true means board changed printf( "redoGame called\n" ); return ret; }