// Declaration of class Board, used by knights tour program // bds 11/98 #include #include /* a knight at position (x,y) can legally move to position (x + xstep[ i ], y + ystep[ i ] ), for i = 0, 1, ..., 7, provided that position is on the board and not occupied by another piece of the same player */ const int xstep[8] = { 1, 1, 2, 2, -1 , -1, -2, -2 }; const int ystep[8] = { 2, -2, 1, -1, 2 , -2, 1, -1 }; // remark: rather than global, these should be static members of class Board class Board { public: int goal; // the number of squares to be filled int last; // the number of pieces on board (and index to last position). Board(int m, int n); // construct a m by n board int validMove( int i ); // true if move number i is a valid move // on current configuration. void extend( int i ); // add move i to current configuration. Must be valid. void unextend(); // remove last move; private: int rows; // number of rows on this board int cols; // number of columns on this board int* x; // array of x-coordinates of the pieces on board in order placed int* y; // array of y-coordinates of the knights on board in order placed int** board; // 2 dim array representing board }; // class Board declaration