Changeset 152 for 06/devel/abstractBoard.cc
- Timestamp:
- 04/14/04 22:27:13 (5 years ago)
- Files:
-
- 1 modified
-
06/devel/abstractBoard.cc (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
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 }
