Changeset 151

Show
Ignore:
Timestamp:
04/14/04 20:25:18 (5 years ago)
Author:
ug
Message:

DEBUG_ABSTRACTBOARD

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • 06/devel/abstractBoard.cc

    r140 r151  
    7474 
    7575abstractBoard::abstractBoard(int bs) throw(BoardError) { 
     76  if (DEBUG_ABSTRACTBOARD) printf("AB::abstractBoard(int) 0\n"); 
    7677  boardsize = bs; 
    7778  if (boardsize < 3) throw BoardError(); 
     
    8081      status[i] = ' '; 
    8182  status[boardsize*boardsize] = 0; 
     83  if (DEBUG_ABSTRACTBOARD) printf("AB::abstractBoard(int) 100\n"); 
    8284} 
    8385 
    8486 
    8587abstractBoard::abstractBoard(const abstractBoard& ab) { 
     88  if (DEBUG_ABSTRACTBOARD) printf("AB::abstractBoard(abstractBoard) 0\n"); 
    8689  printf("copy constructor\n"); 
    8790  boardsize = ab.boardsize; 
     
    9194  status[boardsize*boardsize] = 0; 
    9295  undostack = stack<Move>(ab.undostack); 
     96  if (DEBUG_ABSTRACTBOARD) printf("AB::abstractBoard(abstractBoard) 100\n"); 
    9397} 
    9498 
    9599 
    96100abstractBoard::~abstractBoard() { 
     101  if (DEBUG_ABSTRACTBOARD) printf("AB::~abstractBoard 0\n"); 
    97102  delete []status; 
     103  if (DEBUG_ABSTRACTBOARD) printf("AB::~abstractBoard 100\n"); 
    98104} 
    99105 
    100106abstractBoard& abstractBoard::copy(const abstractBoard& ab) { 
     107  if (DEBUG_ABSTRACTBOARD) printf("AB::copy 0\n"); 
    101108  printf("copy assignment operator\n"); 
    102109  if (this != &ab) { 
     
    109116    undostack = ab.undostack; 
    110117  } 
     118  if (DEBUG_ABSTRACTBOARD) printf("AB::copy 100\n"); 
    111119  return *this; 
    112120} 
    113121 
    114122char abstractBoard::getStatus(int x, int y) { 
     123  if (DEBUG_ABSTRACTBOARD) printf("AB::getStatus 0\n"); 
    115124  return status[boardsize*x + y]; 
    116125} 
     
    118127 
    119128void abstractBoard::setStatus(int x, int y, char val) { 
     129  if (DEBUG_ABSTRACTBOARD) printf("AB::setStatus 0\n"); 
    120130  if (val=='b' || val=='B') status[boardsize*x + y] = 'B'; 
    121131  else if (val=='w' || val=='W') status[boardsize*x + y] = 'W'; 
    122132  else status[boardsize*x + y] = val; 
     133  if (DEBUG_ABSTRACTBOARD) printf("AB::setStatus 100\n"); 
    123134} 
    124135 
    125136 
    126137int abstractBoard::len_cap_last() { 
     138  if (DEBUG_ABSTRACTBOARD) printf("AB::len_cap_last 0\n"); 
    127139  if (!undostack.size()) { 
    128140    return -1; 
     
    135147 
    136148PyObject* abstractBoard::get_cap_last() { 
     149  if (DEBUG_ABSTRACTBOARD) printf("AB::get_cap_last 0\n"); 
    137150  if (!undostack.size()) { 
    138151    Py_INCREF(Py_None); 
     
    145158  for(it = m.captures->begin(); it != m.captures->end(); it++)  
    146159    PyList_Append(cap, Py_BuildValue("(ii)", it->first, it->second)); 
     160  if (DEBUG_ABSTRACTBOARD) printf("AB::get_cap_last 100\n"); 
    147161  return cap; 
    148162} 
    149163 
    150164PyObject* abstractBoard::undostack_pop() { 
     165  if (DEBUG_ABSTRACTBOARD) printf("AB::undostack_pop 0\n"); 
    151166  if (!undostack.size()) { 
    152167    Py_INCREF(Py_None); 
     
    161176      PyList_Append(cap, Py_BuildValue("(ii)", it->first, it->second)); 
    162177  } 
     178  if (DEBUG_ABSTRACTBOARD) printf("AB::undostack_pop 100\n"); 
    163179  return Py_BuildValue("(ii)cO", m.x, m.y, m.c, cap); 
    164180} 
    165181 
    166182void abstractBoard::undostack_append_pass() { 
     183  if (DEBUG_ABSTRACTBOARD) printf("AB::undostack_append_pass 0\n"); 
    167184  undostack.push(Move(20,20,'-')); 
     185  if (DEBUG_ABSTRACTBOARD) printf("AB::undostack_append_pass 100\n"); 
    168186} 
    169187 
    170188int abstractBoard::len_undostack() { 
     189  if (DEBUG_ABSTRACTBOARD) printf("AB::len_undostack 0\n"); 
    171190  return undostack.size(); 
    172191} 
     
    193212 
    194213int abstractBoard::play(PyObject* pos, char* color) throw(BoardError) { 
     214  if (DEBUG_ABSTRACTBOARD) printf("AB::play(PyObject*,char*) 0\n"); 
    195215  int x = PyInt_AsLong(PyTuple_GetItem(pos,0)); 
    196216  int y = PyInt_AsLong(PyTuple_GetItem(pos,1)); 
     
    200220 
    201221int abstractBoard::play(int x, int y, char* color) throw (BoardError) { 
     222  if (DEBUG_ABSTRACTBOARD) printf("AB::play(int,int,char*) 0\n"); 
    202223  if (x<0 || x>=boardsize || y<0 || y>=boardsize) return 0; 
    203224  if (status[boardsize*x+y] != ' ') { 
     
    216237    else delete captures; 
    217238    undostack.push(m); 
     239    if (DEBUG_ABSTRACTBOARD) printf("AB::play(int,int,char*) ret1 100\n"); 
    218240    return 1; 
    219241  }  
     242  if (DEBUG_ABSTRACTBOARD) printf("AB::play(int,int,char*) ret0 200\n"); 
    220243  return 0; 
    221244} 
     
    223246 
    224247vector<p_cc>* abstractBoard::legal(int x, int y, char color) { 
     248  if (DEBUG_ABSTRACTBOARD) printf("AB::legal 0\n"); 
    225249  vector<p_cc>* c = new vector<p_cc>; 
    226250  int* nb = neighbors(x,y); 
     
    270294} 
    271295 
    272  
    273  
    274296vector<p_cc>* abstractBoard::hasNoLibExcP(int x1, int y1, int exc) { 
     297  if (DEBUG_ABSTRACTBOARD) printf("AB::hasNoLibExcP 0\n"); 
    275298  vector<p_cc>* st = new vector<p_cc>; 
    276299  vector<p_cc> newlyFound; 
     
    324347    newlyFound = n; 
    325348  } 
     349  if (DEBUG_ABSTRACTBOARD) printf("AB::hasNoLibExcP 100\n"); 
    326350  return st; 
    327351} 
     
    329353 
    330354void abstractBoard::undo(int n) { 
     355  if (DEBUG_ABSTRACTBOARD) printf("AB::undo 0\n"); 
    331356  for(int i=0; i<n; i++) { 
    332357    if (undostack.size()) { 
     
    346371    } 
    347372  }   
     373  if (DEBUG_ABSTRACTBOARD) printf("AB::undo 100\n"); 
    348374} 
    349375 
    350376 
    351377void abstractBoard::remove(int x, int y) { 
     378  if (DEBUG_ABSTRACTBOARD) printf("AB::remove 0\n"); 
    352379  PyObject* l = PyList_New(0); 
    353380  PyList_Append(l, Py_BuildValue("(ii)", x, y)); 
    354381  undostack.push(Move(-1, -1, invert(status[boardsize*x+y]))); 
    355382  status[boardsize*x+y] = ' '; 
     383  if (DEBUG_ABSTRACTBOARD) printf("AB::remove 100\n"); 
    356384} 
    357385 
  • 06/devel/abstractBoard.h

    r140 r151  
    3030#include <utility> 
    3131#include <stack> 
     32 
     33const int DEBUG_ABSTRACTBOARD = 1; 
     34 
    3235 
    3336class BoardError {