| 1 |
|
|---|
| 2 |
|
|---|
| 3 |
|
|---|
| 4 |
|
|---|
| 5 |
|
|---|
| 6 |
|
|---|
| 7 |
|
|---|
| 8 |
|
|---|
| 9 |
|
|---|
| 10 |
|
|---|
| 11 |
|
|---|
| 12 |
|
|---|
| 13 |
|
|---|
| 14 |
|
|---|
| 15 |
|
|---|
| 16 |
|
|---|
| 17 |
|
|---|
| 18 |
|
|---|
| 19 |
|
|---|
| 20 |
|
|---|
| 21 |
|
|---|
| 22 |
|
|---|
| 23 |
|
|---|
| 24 |
|
|---|
| 25 |
|
|---|
| 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 |
|
|---|
| 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 |
}; |
|---|