root/06/devel-old/pattern.h

Revision 174, 2.9 kB (checked in by ug, 2 years ago)

Worked some more on pattern.cc ... not done yet, though.

Line 
1 // File: pattern.h
2
3 //   Copyright (C) 2004-6 Ulrich Goertz (u@g0ertz.de)
4
5 //   This is part of Kombilo, a go database program.
6
7 //   This program is free software; you can redistribute it and/or modify
8 //   it under the terms of the GNU General Public License as published by
9 //   the Free Software Foundation; either version 2 of the License, or
10 //   (at your option) any later version.
11
12 //   This program is distributed in the hope that it will be useful,
13 //   but WITHOUT ANY WARRANTY; without even the implied warranty of
14 //   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 //   GNU General Public License for more details.
16
17 //   You should have received a copy of the GNU General Public License
18 //   along with this program (see doc/license.txt); if not, write to the Free Software
19 //   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
20 //   The GNU GPL is also currently available at
21 //   http://www.gnu.org/copyleft/gpl.html
22
23
24 using namespace std;
25
26 #include "Python.h"
27 #include <vector>
28
29 typedef char* charp;
30
31 class Symmetries {
32  public:
33   int* dataX;
34   int* dataY;
35   int* dataCS;
36   int sizeX;
37   int sizeY;
38   Symmetries(int sX=0, int sY=0);
39   ~Symmetries();
40   Symmetries(const Symmetries& s);
41   Symmetries& operator=(const Symmetries& s);
42   void set(int i, int j, int k, int l, int cs);
43   int getX(int i, int j);
44   int getY(int i, int j);
45   int getCS(int i, int j);
46   int has_key(int i, int j);
47   int special;
48 };
49
50 class Pattern {
51  public:
52   int left; // left, right, top, bottom "==" anchors
53   int right;
54   int bottom;
55   int top;
56   int sizeX;
57   int sizeY;
58
59   int flip, colorSwitch;
60   char moveOne, moveTwo;
61   charp* bits;
62         int* bitlengths;
63   char* initialPos;
64   char* finalPos;
65   char* contList;
66   int lenContList;
67
68   Pattern();
69   Pattern(int le, int ri, int to, int bo, int sX, int sY,
70                 char* iPos, char* cList, int lenCList, char mOne);
71   Pattern(const Pattern& p);
72   ~Pattern();
73   Pattern& copy(const Pattern& p);
74
75   char getInitial(int i, int j);
76   char getFinal(int i, int j);
77   int getBits(int b, int i);
78
79   char BW2XO(char c);
80   int operator==(const Pattern& p);
81         void printPattern();
82
83   static int flipsX(int i, int x, int y, int XX, int YY);
84   static int flipsY(int i, int x, int y, int XX, int YY);
85   static int PatternInvFlip(int i);
86
87 };
88
89
90 class PatternList {
91  public:
92   int boardsize;
93   Pattern pattern;
94   int fixedColor, nextMove;
95   vector<Pattern> data;
96   Symmetries symmetries;
97
98   PatternList(Pattern& p, int fColor, int nMove, int bsize);
99   PatternList(const PatternList& pl);
100   PatternList& operator=(const PatternList& pl);
101
102   char invertColor(char co);
103   vector<Pattern> patternList();
104   Pattern& get(int i);
105   int size();
106   PyObject* updateContinuations(int index, int x, int y, char co, int Xint0, int Xint1,
107                                 int Yint0, int Yint1,
108                                 int foundWhere, int counter,
109                                 PyObject* continuations, char* contLabels, int contLabelsIndex,
110                                 char winner);
111 };
112
Note: See TracBrowser for help on using the browser.