root/06/libkombilo-branches/hash_center_makedb/abstractboard.h

Revision 191, 2.6 kB (checked in by ug, 2 years ago)

Minor fixes (namespaces, Borland compatibility, sqlite_busy_timeout, ...).

Line 
1 // File: abstractboard.h
2 // part of libkombilo, http://www.u-go.net/kombilo/
3
4 // Copyright (c) 2006 Ulrich Goertz <u@g0ertz.de>
5
6 // Permission is hereby granted, free of charge, to any person obtaining a copy of
7 // this software and associated documentation files (the "Software"), to deal in
8 // the Software without restriction, including without limitation the rights to
9 // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
10 // of the Software, and to permit persons to whom the Software is furnished to do
11 // so, subject to the following conditions:
12 //
13 // The above copyright notice and this permission notice shall be included in all
14 // copies or substantial portions of the Software.
15 //
16 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 // SOFTWARE.
23
24 #ifndef _ABSTRACTBOARD_H_
25 #define _ABSTRACTBOARD_H_
26
27 #include <vector>
28 #include <utility>
29 #include <stack>
30
31 const int DEBUG_ABSTRACTBOARD = 0;
32
33 class BoardError {
34  public:
35   BoardError();
36 };
37
38 typedef std::pair<char,char> p_cc;
39
40
41 class MoveNC {
42   public:
43     char x;
44     char y;
45     char color;
46
47     MoveNC();
48     MoveNC(char X, char Y, char COLOR);
49     bool operator==(const MoveNC& mnc) const;
50 };
51
52 class Move : public MoveNC {
53   public:
54     Move(char xx, char yy, char cc);
55     Move(const Move& m);
56     ~Move();
57     Move& operator=(const Move& m);
58
59     std::vector<p_cc >* captures;
60 };
61
62
63 class abstractBoard {
64   public:
65     int boardsize;
66     char* status;
67     std::stack<Move> undostack;
68
69     abstractBoard(int bs = 19) throw(BoardError);
70     abstractBoard(const abstractBoard& ab);
71     ~abstractBoard();
72     abstractBoard& operator=(const abstractBoard& ab);
73     void clear();
74     int play(int x, int y, char* color) throw(BoardError);
75     void undo(int n=1);
76     void remove(int x, int y);
77     char getStatus(int x, int y);
78     void setStatus(int x, int y, char val);
79     int len_cap_last() throw(BoardError);
80     void undostack_append_pass();
81     // abstractBoard& copy(const abstractBoard& ab);
82
83   private:
84     int* neighbors(int x, int y);
85     std::vector<p_cc >* legal(int x, int y, char color);
86     std::vector<p_cc >* hasNoLibExcP(int x1, int y1, int exc=-1);
87     char invert(char);
88 };
89
90 #endif
91
Note: See TracBrowser for help on using the browser.