/* This may look like c to you, but it's really -*-c++-*- */ /* GMA or "The Go-moku Apprentice" is a go-moku implementation that learns * the game from its own (and its opponents') mistakes. * Copyright (C) 1998 Johan Walles (d92-jwa@nada.kth.se) * * 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 PATTERN_H #define PATTERN_H #include #define PATTERN_EMPTY 0 #define PATTERN_MINE 1 #define PATTERN_YOURS 2 #define PATTERN_DONTCARE 3 class Pattern { public: bool operator==(const Pattern p2) const { return memcmp(chars, p2.chars, 8) == 0; } bool operator<(const Pattern p2) const { return memcmp(chars, p2.chars, 8) < 0; } unsigned char & operator[](const int i) { return chars[i]; } unsigned char get_char(const int i) const { return chars[i]; } unsigned char * tochars() { return chars; } void fromchars(unsigned char inchars[8]) { memcpy(chars, inchars, 8); } unsigned int nth_axis(int n) const { return ((chars[2 * n]) << 8) + chars[2 * n + 1]; } bool null() const { return !(chars[0] || chars[1] || chars[2] || chars[3] || chars[4] || chars[5] || chars[6] || chars[7]); } int winner() const; protected: unsigned char chars[8]; }; #endif // ifndef PATTERN_H