root/06/devel-old/abstractBoard.h

Revision 153, 2.3 kB (checked in by ug, 4 years ago)

Continued transcoding patternPY

Line 
1 // File: abstractBoard.h
2
3 //   Copyright (C) 2004 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 // (internal) board coordinates 0,...,boardsize-1
24 // communication should probably be done via SGF coord.
25 // color == 'B' / 'W'
26
27 using namespace std;
28
29 #include "Python.h"
30 #include <vector>
31 #include <utility>
32 #include <stack>
33
34 const int DEBUG_ABSTRACTBOARD = 0;
35
36
37 class BoardError {
38  public:
39   BoardError();
40 };
41
42 typedef pair<char,char> p_cc;
43
44 class Move {
45  public:
46   Move(char xx, char yy, char cc);
47   Move(const Move& m);
48   ~Move();
49   Move& copy(const Move& m);
50
51   char x;
52   char y;
53   char c;
54   vector<pair<char,char> >* captures;
55 };
56
57
58 class abstractBoard {
59  public:
60   int boardsize;
61   char* status;
62   stack<Move> undostack;
63
64   abstractBoard(int bs = 19) throw(BoardError);
65   abstractBoard(const abstractBoard& ab);
66   ~abstractBoard();
67   // abstractBoard& operator=(const abstractBoard& ab);
68   void clear();
69   int play(PyObject* pos, char* color) throw(BoardError);
70   int play(int x, int y, char* color) throw(BoardError);
71   void undo(int n=1);
72   void remove(int x, int y);
73   char getStatus(int x, int y);
74   void setStatus(int x, int y, char val);
75   int len_cap_last();
76   PyObject* get_cap_last();
77   PyObject* undostack_pop();
78   void undostack_append_pass();
79   int len_undostack();
80   abstractBoard& copy(const abstractBoard& ab);
81
82  private:
83   int* neighbors(int x, int y);
84   vector<pair<char,char> >* legal(int x, int y, char color);
85   vector<pair<char,char> >* hasNoLibExcP(int x1, int y1, int exc=-1);
86   char invert(char);
87 };
Note: See TracBrowser for help on using the browser.