Changeset 152
- Timestamp:
- 04/14/04 22:27:13 (4 years ago)
- Files:
-
- 06/devel/abstractBoard.cc (modified) (8 diffs)
- 06/devel/abstractBoard.h (modified) (1 diff)
- 06/devel/abstractBoardPY.py (modified) (1 diff)
- 06/devel/board.py (modified) (1 diff)
- 06/devel/kombilo.py (modified) (1 diff)
- 06/devel/v.app (added)
- 06/devel/v.py (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
06/devel/abstractBoard.cc
r151 r152 254 254 if (status[boardsize*x1 + y1] == invert(color)) { 255 255 vector<p_cc>* d = hasNoLibExcP(x1, y1, x*boardsize+y); 256 if (DEBUG_ABSTRACTBOARD) printf("AB::legal 39\n"); 257 if (DEBUG_ABSTRACTBOARD) printf("AB::legal 40, %d\n", d->size()); 256 258 vector<p_cc>::iterator it; 257 for(it = d->begin(); it != d->end(); d++) c->push_back(*it); 259 for(it = d->begin(); it != d->end(); it++) c->push_back(*it); 260 if (DEBUG_ABSTRACTBOARD) printf("AB::legal 41\n"); 258 261 delete d; 259 262 } 260 263 } 261 264 if (DEBUG_ABSTRACTBOARD) printf("AB::legal 42\n"); 262 265 setStatus(x,y,color); 263 266 … … 278 281 } 279 282 delete c; 283 if (DEBUG_ABSTRACTBOARD) printf("AB::legal 98\n"); 280 284 return captures; 281 285 } 282 286 delete c; 283 287 vector<p_cc>* d = hasNoLibExcP(x, y); 288 if (DEBUG_ABSTRACTBOARD) printf("AB::legal 49\n"); 289 if (DEBUG_ABSTRACTBOARD) printf("AB::legal 50, %d\n", d->size()); 284 290 if (d->size()) { 285 291 delete d; 286 292 status[boardsize*x + y] = ' '; 293 if (DEBUG_ABSTRACTBOARD) printf("AB::legal 99\n"); 287 294 return 0; 288 295 } … … 290 297 delete d; 291 298 vector<p_cc>* ret = new vector<p_cc>(); 299 if (DEBUG_ABSTRACTBOARD) printf("AB::legal 100\n"); 292 300 return ret; 293 301 } … … 297 305 if (DEBUG_ABSTRACTBOARD) printf("AB::hasNoLibExcP 0\n"); 298 306 vector<p_cc>* st = new vector<p_cc>; 299 vector<p_cc> newlyFound;300 newlyFound .push_back(p_cc(x1, y1));301 307 vector<p_cc>* newlyFound = new vector<p_cc>; 308 newlyFound->push_back(p_cc(x1, y1)); 309 vector<p_cc>* n; 302 310 int foundNew = 1; 303 311 304 312 while (foundNew) { 305 313 foundNew = 0; 306 vector<p_cc> n;307 for(unsigned int i=0; i < newlyFound.size(); i++) {308 p_cc tup = newlyFound[i];309 int x = tup.first;310 int y = tup.second;314 n = new vector<p_cc>; 315 vector<p_cc>::iterator it1; 316 for(it1=newlyFound->begin(); it1!=newlyFound->end(); it1++) { 317 int x = it1->first; 318 int y = it1->second; 311 319 int* nbs = neighbors(x,y); 320 if (DEBUG_ABSTRACTBOARD) printf("AB::hasNoLibExcP 7 (%d,%d) %d\n",x, y,nbs[0]); 312 321 for (int j=1; j <= nbs[0]; j++) { 313 322 int yy1 = nbs[j]; 323 if (DEBUG_ABSTRACTBOARD) printf("AB::hasNoLibExcP 99\n"); 314 324 if (status[yy1] == ' ' && yy1 != exc) { 315 325 delete [] nbs; … … 317 327 } 318 328 else { 319 p_cc yy(yy1/boardsize, yy1%boardsize);320 329 if (status[yy1]==status[x*boardsize+y]) { 321 foundNew = 1; 330 p_cc yy(yy1/boardsize, yy1%boardsize); 331 int foundNewHere = 1; 322 332 vector<p_cc>::iterator it; 323 333 for(it = st->begin(); it!=st->end(); it++) { 324 334 if (it->first==yy.first && it->second==yy.second) { 325 foundNew = 0;335 foundNewHere = 0; 326 336 break; 327 337 } 328 338 } 329 if (foundNew ) {330 for(it=newlyFound .begin(); it!=newlyFound.end(); it++) {339 if (foundNewHere) { 340 for(it=newlyFound->begin(); it!=newlyFound->end(); it++) { 331 341 if (it->first==yy.first && it->second==yy.second) { 332 foundNew = 0;342 foundNewHere = 0; 333 343 break; 334 344 } 335 345 } 336 346 } 337 if (foundNew) n.push_back(yy); 347 if (foundNewHere) { 348 n->push_back(yy); 349 foundNew = 1; 350 } 338 351 } 339 352 } … … 343 356 344 357 vector<p_cc>::iterator it; 345 for(it=newlyFound.begin(); it!=newlyFound.end(); it++) 358 for(it=newlyFound->begin(); it!=newlyFound->end(); it++) { 359 if (DEBUG_ABSTRACTBOARD) printf("AB::hasNoLibExcP 10, (%d,%d)\n", it->first, it->second); 346 360 st->push_back(*it); 361 } 362 delete newlyFound; 347 363 newlyFound = n; 348 364 } 349 365 if (DEBUG_ABSTRACTBOARD) printf("AB::hasNoLibExcP 100\n"); 366 delete n; 350 367 return st; 351 368 } … … 355 372 if (DEBUG_ABSTRACTBOARD) printf("AB::undo 0\n"); 356 373 for(int i=0; i<n; i++) { 374 if (DEBUG_ABSTRACTBOARD) printf("AB::undo 1 %d\n", i); 357 375 if (undostack.size()) { 358 376 Move tuple = undostack.top(); … … 365 383 366 384 status[x*boardsize+y] = ' '; 367 for(unsigned int i=0; i < captures->size(); i++) { 368 p_cc t = (*captures)[i]; 369 setStatus(t.first, t.second, invert(color)); 385 if (captures) { 386 for(unsigned int i=0; i < captures->size(); i++) { 387 p_cc t = (*captures)[i]; 388 setStatus(t.first, t.second, invert(color)); 389 } 370 390 } 371 391 } 06/devel/abstractBoard.h
r151 r152 31 31 #include <stack> 32 32 33 const int DEBUG_ABSTRACTBOARD = 1;33 const int DEBUG_ABSTRACTBOARD = 0; 34 34 35 35 06/devel/abstractBoardPY.py
r123 r152 171 171 for x in newlyFound: 172 172 for y in self.neighbors(x): 173 if not self.getStatus(y[0], y[1]) != ' ' and y != exc: # found a liberty173 if self.getStatus(y[0], y[1]) == ' ' and y != exc: # found a liberty 174 174 return [] 175 elif self.getStatus(y[0],y[1]) !=' ' and self.getStatus(y[0],y[1])==self.getStatus(x[0],x[1]) \175 elif self.getStatus(y[0],y[1])==self.getStatus(x[0],x[1]) \ 176 176 and not y in st and not y in newlyFound: # found another stone of same color 177 177 n.append(y) 06/devel/board.py
r147 r152 30 30 import sys 31 31 import os 32 #try:33 #from abstractBoard import *34 #except ImportError:35 from abstractBoardPY import *32 try: 33 from abstractBoard import * 34 except ImportError: 35 from abstractBoardPY import * 36 36 37 37 06/devel/kombilo.py
r147 r152 53 53 import webbrowser 54 54 55 #try:56 #from abstractBoard import *57 #except ImportError:58 #print 'ouch' # FIXME59 from abstractBoardPY import *55 try: 56 from abstractBoard import * 57 except ImportError: 58 print 'ouch' # FIXME 59 from abstractBoardPY import * 60 60 from board import * 61 61 import v 06/devel/v.py
r147 r152 45 45 from sgfparser import Node, Cursor, SGFError, SGFescape 46 46 47 #try:48 #from abstractBoard import *49 #except ImportError:50 ## print 'ouch' # FIXME51 from abstractBoardPY import *47 try: 48 from abstractBoard import * 49 except ImportError: 50 # print 'ouch' # FIXME 51 from abstractBoardPY import * 52 52 from board import * 53 53 # from gtp import GTP
