libkombilo  0.7
/home/ug/devel/kombilo/lk/abstractboard.h
Go to the documentation of this file.
00001 
00026 #ifndef _ABSTRACTBOARD_H_
00027 #define _ABSTRACTBOARD_H_
00028 
00029 #include <vector>
00030 #include <utility>
00031 #include <stack>
00032 #include <iostream>
00033 
00034 class BoardError {
00035  public:
00036   BoardError();
00037 };
00038 
00039 typedef std::pair<int,int> p_cc;
00040 
00041 
00042 const char AB = 'x';
00043 const char AW = 'y';
00044 const char AEB = 'z'; // remove a black stone
00045 const char AEW = 'Z'; // remove a white stone
00046 
00047 
00048 
00049 class MoveNC {
00050   public:
00051     char x;
00052     char y;
00053     char color;
00054 
00055     MoveNC();
00056     MoveNC(char X, char Y, char COLOR);
00057     MoveNC(const MoveNC& MNC);
00058     bool operator==(const MoveNC& mnc) const;
00059 };
00060 
00061 class Move : public MoveNC {
00062   public:
00063     Move();
00064     Move(char xx, char yy, char cc);
00065     Move(char xx, char yy, char cc, std::vector<p_cc > cap);
00066     Move(const Move& m);
00067     ~Move();
00068     Move& operator=(const Move& m);
00069 
00070     std::vector<p_cc >* captures;
00071 };
00072 
00073 
00077 class abstractBoard {
00078   public:
00079     int boardsize;
00080     std::vector<Move> undostack;
00081 
00082     abstractBoard(int bs = 19) throw(BoardError);
00083     abstractBoard(const abstractBoard& ab);
00084     ~abstractBoard();
00085     abstractBoard& operator=(const abstractBoard& ab);
00086 
00087     void clear(); 
00088     int play(int x, int y, const char* color) throw(BoardError);
00090     void undo(int n=1); 
00091     void remove(int x, int y, bool removeFromUndostack);
00092     char getStatus(int x, int y);
00093     void setStatus(int x, int y, char val);
00094 
00098 
00099     int len_cap_last() throw(BoardError);
00100     void undostack_append_pass();
00101     p_cc undostack_top_pos();
00102     char undostack_top_color();
00103     std::vector<p_cc > undostack_top_captures();
00104     void undostack_push(Move& m);
00105     void undostack_pop();
00108     // abstractBoard& copy(const abstractBoard& ab);
00109 
00110   private:
00111     char* status;
00112     int* neighbors(int x, int y);
00113     std::vector<p_cc >* legal(int x, int y, char color);
00114     std::vector<p_cc >* hasNoLibExcP(int x1, int y1, int exc=-1);
00115     char invert(char);
00116 };
00117 
00118 #endif
00119 
 All Data Structures Files Functions Variables