first-draft of crop feature and problem theme
[eidogo-ojd.git] / kombilo / abstractboard.h
blobc03917cbce84a3a747351da8262481d970ccdc00
1 // File: abstractboard.h
2 // part of libkombilo, http://www.u-go.net/kombilo/
4 // Copyright (c) 2006 Ulrich Goertz <u@g0ertz.de>
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.
24 #ifndef _ABSTRACTBOARD_H_
25 #define _ABSTRACTBOARD_H_
27 #include <vector>
28 #include <utility>
29 #include <stack>
31 class BoardError {
32 public:
33 BoardError();
36 typedef std::pair<char,char> p_cc;
39 class MoveNC {
40 public:
41 char x;
42 char y;
43 char color;
45 MoveNC();
46 MoveNC(char X, char Y, char COLOR);
47 bool operator==(const MoveNC& mnc) const;
50 class Move : public MoveNC {
51 public:
52 Move(char xx, char yy, char cc);
53 Move(const Move& m);
54 ~Move();
55 Move& operator=(const Move& m);
57 std::vector<p_cc >* captures;
61 class abstractBoard {
62 public:
63 int boardsize;
64 char* status;
65 std::stack<Move> undostack;
67 abstractBoard(int bs = 19) throw(BoardError);
68 abstractBoard(const abstractBoard& ab);
69 ~abstractBoard();
70 abstractBoard& operator=(const abstractBoard& ab);
71 void clear();
72 int play(int x, int y, char* color) throw(BoardError);
73 void undo(int n=1);
74 void remove(int x, int y);
75 char getStatus(int x, int y);
76 void setStatus(int x, int y, char val);
77 int len_cap_last() throw(BoardError);
78 void undostack_append_pass();
79 // abstractBoard& copy(const abstractBoard& ab);
81 private:
82 int* neighbors(int x, int y);
83 std::vector<p_cc >* legal(int x, int y, char color);
84 std::vector<p_cc >* hasNoLibExcP(int x1, int y1, int exc=-1);
85 char invert(char);
88 #endif