/* * Gnome Nine Mens Morris * Written by Dirk Farin * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #ifndef NMM_BOARD_HH #define NMM_BOARD_HH #define EMPTY 0 #define WHITE 1 #define BLACK -1 typedef short piece; void InitMillTab(); extern int neighbour[3*8][4]; extern char milltab[3*8][2][2]; extern char milltab_short[16][3]; struct Move { Move() { } Move(const char*); void Reset() { start = end = take = -1; } bool IsEmpty() { return end==-1; } char start; char end; char take; }; struct Board { piece board[3*8]; char next; char n_white; char n_black; int ply; void Init(); void DoMove(const Move&); void MoveToString(const Move&,char* buf) const; bool CurrentHasLost() const; bool OpponentHasLost() const; int GenMoves(Move* result,int maxMoves) const; // returns number of moves bool WouldCloseMill(int s,int e) const; bool IsInMill(int n) const; int Freedom(int n) const; private: int GenTakes(Move* result) const; }; #endif