Changeset 183
- Timestamp:
- 09/22/06 20:53:40 (2 years ago)
- Files:
-
- 06/libkombilo/abstractboard.cc (modified) (2 diffs)
- 06/libkombilo/abstractboard.h (modified) (1 diff)
- 06/libkombilo/cpptest.cc (modified) (1 diff)
- 06/libkombilo/libkombilo.i (modified) (1 diff)
- 06/libkombilo/search.cc (modified) (40 diffs)
- 06/libkombilo/search.h (modified) (5 diffs)
- 06/libkombilo/sgfparser.cc (modified) (1 diff)
- 06/libkombilo/sgfparser.h (modified) (1 diff)
- 06/libkombilo/testhash.py (modified) (2 diffs)
- 06/libkombilo/testsearch.py (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
06/libkombilo/abstractboard.cc
r177 r183 26 26 BoardError::BoardError() {} 27 27 28 // coordinates used here: (1,1)-(19,19) 28 MoveNC::MoveNC() { 29 x = -1; 30 y = -1; 31 color = ' '; 32 } 33 34 // coordinates used here: (1,1)-(19,19) FIXME what? 29 35 MoveNC::MoveNC(char X, char Y, char COLOR) { 30 36 x = X; … … 33 39 } 34 40 35 bool MoveNC::operator==(const MoveNC& mnc) {41 bool MoveNC::operator==(const MoveNC& mnc) const { 36 42 if (x == mnc.x && y == mnc.y && color == mnc.color) return true; 37 43 else return false; 06/libkombilo/abstractboard.h
r177 r183 46 46 char color; 47 47 48 MoveNC(); 48 49 MoveNC(char X, char Y, char COLOR); 49 bool operator==(const MoveNC& mnc) ;50 bool operator==(const MoveNC& mnc) const; 50 51 }; 51 52 06/libkombilo/cpptest.cc
r182 r183 2 2 3 3 int main() { 4 GameList gl("t1.db", "id", "[[PW]] - [[PB]] ([[winner]]), [[filename ]]", ALGO_FINALPOS | ALGO_MOVELIST | ALGO_HASH_FULL, 19);4 GameList gl("t1.db", "id", "[[PW]] - [[PB]] ([[winner]]), [[filename.]]", ALGO_FINALPOS | ALGO_MOVELIST | ALGO_HASH_FULL, 19); 5 5 // gl.gisearch("pw = 'Hane Naoki'"); 6 6 // Pattern p(CENTER_PATTERN, 19, 3, 5, ".X..OX.OX.OXOXO") ; 7 Pattern p(FULLBOARD_PATTERN, 19, 19, 19, ".....................O.O........OX......XO......X.OXX.XX...X,.OOXXX..OOOX.O....X.OXOOXOO..OX.......XOXXOXXOOXXOO....OX.XXXOOOXO.O.O...OXX..XOX..XO.X.XO...O.......X.....XO..O.,X....,.....XOO................X......X............X....O...........................................O.O...........O.....,.....X...........X.O.X............................................"); 8 PatternList pl(p, 0, 0, 19); 7 vector<MoveNC> contList; 8 contList.push_back(MoveNC(6,15,'X')); 9 contList.push_back(MoveNC(6,13,'O')); 10 contList.push_back(MoveNC(4,15,'X')); 11 Pattern p(FULLBOARD_PATTERN, 19, 19, 19, ".....................O.O........OX......XO......X.OXX.XX...X,.OOXXX..OOOX.O....X.OXOOXOO..OX.......XOXXOXXOOXXOO....OX.XXXOOOXO.O.O...OXX..XOX..XO.X.XO...O.......X.....XO..O.,X....,.....XOO................X......X............X....O...........................................O.O...........O.....,.....X...........X.O.X............................................", contList); 9 12 SearchOptions so; 10 gl.search(p l, so);13 gl.search(p, so); 11 14 printf("num games: %d\n", gl.size()); 15 vector<string> res = gl.currentEntriesAsStrings(); 16 for(vector<string>::iterator it = res.begin(); it != res.end(); it++) 17 printf("%s\n", it->c_str()); 12 18 } 06/libkombilo/libkombilo.i
r177 r183 16 16 %include "abstractboard.h" 17 17 %include "search.h" 18 %template(vectorMNC) vector<MoveNC>; 18 19 20 06/libkombilo/search.cc
r182 r183 136 136 if (sizeX != p.sizeX || sizeY != p.sizeY) return 0; 137 137 if (left != p.left || right != p.right || top != p.top || bottom != p.bottom) return 0; 138 // if (moveOne != p.moveOne) return 0;139 138 for(int i=0; i < sizeX*sizeY; i++) 140 139 if (initialPos[i] != p.initialPos[i]) return 0; 141 for(int i=0; i < 4*lenContList; i++) 142 if (contList[i] != p.contList[i]) return 0; 140 if (contList != p.contList) return 0; 143 141 return 1; 144 142 } … … 163 161 initialPos = 0; 164 162 finalPos = 0; 165 contList = 0;166 163 flip = 0; 167 164 colorSwitch = 0; … … 171 168 172 169 173 Pattern::Pattern(int type, int boardsize, int sX, int sY, 174 char* iPos, char* cList, int lenCList, char mOne) { 170 Pattern::Pattern(int type, int boardsize, int sX, int sY, char* iPos) { 175 171 flip = 0; 176 172 colorSwitch = 0; 177 if (mOne=='B' || mOne=='X') moveOne = 'X';178 else moveOne = 'O';179 if (moveOne == 'X') moveTwo = 'O';180 else moveTwo = 'X';181 173 sizeX = sX; 182 174 sizeY = sY; … … 221 213 finalPos[i] = iPos[i]; 222 214 } 223 224 lenContList = lenCList; 225 contList = new char[lenCList*4+1]; 226 for(int i=0; i<4*lenCList; i++) contList[i] = cList[i]; 227 for(int i=0; i<lenContList; i++) { 228 finalPos[contList[4*i] + sizeX * contList[4*i+1]] = BW2XO(contList[4*i+2]); 229 } 230 contList[lenCList*4] = 0; 231 } 232 233 Pattern::Pattern(int le, int ri, int to, int bo, int sX, int sY, 234 char* iPos, char* cList, int lenCList, char mOne) { 215 } 216 217 Pattern::Pattern(int type, int boardsize, int sX, int sY, 218 char* iPos, vector<MoveNC> CONTLIST) { 235 219 flip = 0; 236 220 colorSwitch = 0; 237 if (mOne=='B' || mOne=='X') moveOne = 'X';238 else moveOne = 'O';239 if (moveOne == 'X') moveTwo = 'O';240 else moveTwo = 'X';241 242 left = le;243 right = ri;244 top = to;245 bottom = bo;246 247 221 sizeX = sX; 248 222 sizeY = sY; 223 224 if (type == CORNER_NW_PATTERN || type == FULLBOARD_PATTERN) { 225 left = right = top = bottom = 0; 226 } else if (type == CORNER_NE_PATTERN) { 227 top = bottom = 0; 228 left = right = boardsize -1 - sizeX; 229 } else if (type == CORNER_SE_PATTERN) { 230 top = bottom = boardsize -1 - sizeY; 231 left = right = boardsize -1 - sizeX; 232 } else if (type == CORNER_SW_PATTERN) { 233 top = bottom = boardsize -1 - sizeY; 234 left = right = 0; 235 } else if (type == SIDE_N_PATTERN) { 236 top = bottom = 0; 237 left = 1; 238 right = boardsize -1 - sizeX; 239 } else if (type == SIDE_E_PATTERN) { 240 left = right = boardsize -1 - sizeX; 241 top = 1; 242 bottom = boardsize -1 - sizeY; 243 } else if (type == SIDE_W_PATTERN) { 244 left = right = 0; 245 top = 1; 246 bottom = boardsize -1 - sizeY; 247 } else if (type == SIDE_S_PATTERN) { 248 top = bottom = boardsize -1 - sizeY; 249 left = 1; 250 right = boardsize -1 - sizeX; 251 } else if (type == CENTER_PATTERN) { 252 left = top = 1; 253 right = boardsize -1 - sizeX; 254 bottom = boardsize -1 - sizeY; 255 } 249 256 250 257 initialPos = new char[sizeX * sizeY]; … … 255 262 } 256 263 257 lenContList = lenCList; 258 contList = new char[lenCList*4+1]; 259 for(int i=0; i<4*lenCList; i++) contList[i] = cList[i]; 260 for(int i=0; i<lenContList; i++) { 261 finalPos[contList[4*i] + sizeX * contList[4*i+1]] = BW2XO(contList[4*i+2]); 264 contList = CONTLIST; 265 } 266 267 Pattern::Pattern(int le, int ri, int to, int bo, int sX, int sY, 268 char* iPos, const vector<MoveNC>& CONTLIST) { 269 flip = 0; 270 colorSwitch = 0; 271 272 left = le; 273 right = ri; 274 top = to; 275 bottom = bo; 276 277 sizeX = sX; 278 sizeY = sY; 279 280 initialPos = new char[sizeX * sizeY]; 281 finalPos = new char[sizeX*sizeY]; 282 for(int i=0; i<sizeX*sizeY; i++) { 283 initialPos[i] = iPos[i]; 284 finalPos[i] = iPos[i]; 262 285 } 263 contList[lenCList*4] = 0; 286 287 contList = CONTLIST; 264 288 } 265 289 … … 267 291 if (initialPos) delete [] initialPos; 268 292 if (finalPos) delete [] finalPos; 269 if (contList) delete [] contList;270 293 } 271 294 … … 279 302 flip = p.flip; 280 303 colorSwitch = p.colorSwitch; 281 moveOne = p.moveOne;282 moveTwo = p.moveTwo;283 304 284 305 initialPos = new char[sizeX*sizeY]; … … 288 309 finalPos[i] = p.finalPos[i]; 289 310 } 290 lenContList = p.lenContList; 291 if (lenContList) { 292 contList = new char[lenContList*4]; 293 for(int i = 0; i < lenContList*4; i++) contList[i] = p.contList[i]; 294 } 295 else contList = 0; 311 contList = p.contList; 296 312 } 297 313 … … 306 322 flip = p.flip; 307 323 colorSwitch = p.colorSwitch; 308 moveOne = p.moveOne;309 moveTwo = p.moveTwo;310 324 311 325 if (initialPos) delete [] initialPos; 312 326 if (finalPos) delete [] finalPos; 313 if (contList) delete [] contList;314 327 315 328 initialPos = new char[sizeX*sizeY]; … … 319 332 finalPos[i] = p.finalPos[i]; 320 333 } 321 lenContList = p.lenContList; 322 contList = new char[lenContList*4+1]; 323 for(int i = 0; i < lenContList*4; i++) contList[i] = p.contList[i]; 324 contList[lenContList*4] = 0; 325 334 contList = p.contList; 326 335 } 327 336 return *this; … … 339 348 flip = p.flip; 340 349 colorSwitch = p.colorSwitch; 341 moveOne = p.moveOne;342 moveTwo = p.moveTwo;343 350 344 351 if (initialPos) delete [] initialPos; 345 352 if (finalPos) delete [] finalPos; 346 if (contList) delete [] contList;347 353 348 354 initialPos = new char[sizeX*sizeY]; … … 352 358 finalPos[i] = p.finalPos[i]; 353 359 } 354 lenContList = p.lenContList; 355 contList = new char[lenContList*4+1]; 356 for(int i = 0; i < lenContList*4; i++) contList[i] = p.contList[i]; 357 contList[lenContList*4] = 0; 360 contList = p.contList; 358 361 } 359 362 return *this; … … 473 476 } 474 477 475 char* newContList = new char[pattern.lenContList*4+1]; 476 for(int i=0; i<pattern.lenContList; i++) { 477 newContList[4*i] = Pattern::flipsX(f, pattern.contList[4*i], pattern.contList[4*i+1], 478 pattern.sizeX-1,pattern.sizeY-1); 479 newContList[4*i+1] = Pattern::flipsY(f, pattern.contList[4*i], pattern.contList[4*i+1], 480 pattern.sizeX-1,pattern.sizeY-1); 481 newContList[4*i+2] = pattern.contList[4*i+2]; 482 newContList[4*i+3] = '/'; // FIXME: ist doch so Verschwendung 478 vector<MoveNC> newContList; 479 for(int i=0; i<pattern.contList.size(); i++) { 480 newContList.push_back(MoveNC(Pattern::flipsX(f, pattern.contList[i].x, pattern.contList[i].y, 481 pattern.sizeX-1,pattern.sizeY-1), 482 Pattern::flipsY(f, pattern.contList[i].x, pattern.contList[i].y, 483 pattern.sizeX-1,pattern.sizeY-1), 484 pattern.contList[i].color)); 483 485 } 484 newContList[pattern.lenContList*4] = 0;485 486 486 487 Pattern pNew(newLeft, newRight, newTop, newBottom, newSizeX, newSizeY, 487 newInitialPos, newContList , pattern.lenContList, pattern.moveOne);488 newInitialPos, newContList); 488 489 489 490 pNew.flip = f; … … 491 492 492 493 delete [] newInitialPos; 493 delete [] newContList;494 494 495 495 vector<Pattern>::iterator it; … … 513 513 } 514 514 } 515 516 char* newContList = new char[pattern.lenContList*4+1]; 517 for(int i=0; i<pattern.lenContList; i++) { 518 newContList[4*i] = Pattern::flipsX(f, pattern.contList[4*i], pattern.contList[4*i+1], pattern.sizeX-1,pattern.sizeY-1); 519 newContList[4*i+1] = Pattern::flipsY(f, pattern.contList[4*i], pattern.contList[4*i+1], pattern.sizeX-1,pattern.sizeY-1); 520 newContList[4*i+2] = invertColor(pattern.contList[4*i+2]); 521 newContList[4*i+3] = '/'; // FIXME siehe oben 522 }523 newContList[pattern.lenContList*4] = 0; 515 vector<MoveNC> newContList; 516 for(int i=0; i<pattern.contList.size(); i++) { 517 newContList.push_back(MoveNC(Pattern::flipsX(f, pattern.contList[i].x, pattern.contList[i].y, 518 pattern.sizeX-1,pattern.sizeY-1), 519 Pattern::flipsY(f, pattern.contList[i].x, pattern.contList[i].y, 520 pattern.sizeX-1,pattern.sizeY-1), 521 invertColor(pattern.contList[i].color))); 522 } 523 524 524 525 525 // printf("new size %d %d", newSizeX, newSizeY); 526 526 Pattern pNew1(newLeft, newRight, newTop, newBottom, newSizeX, newSizeY, 527 newInitialPos, newContList , pattern.lenContList, pattern.moveTwo);527 newInitialPos, newContList); 528 528 pNew1.flip = f; 529 529 pNew1.colorSwitch = 1; 530 530 531 531 delete [] newInitialPos; 532 delete [] newContList;533 532 534 533 if (!fixedColor) { … … 1265 1264 } 1266 1265 1266 1267 MovelistCand::MovelistCand(Pattern* P, int ORIENTATION, char* DICTS, int NO, char X, char Y) { 1268 orientation = ORIENTATION; 1269 p = P; 1270 mx = X; 1271 my = Y; 1272 Xinterv = make_pair(mx, mx+p->sizeX); 1273 Yinterv = make_pair(my, my+p->sizeY); 1274 1275 dicts = DICTS; 1276 dictsNO = NO; 1277 contListIndex = 0; 1278 dictsF = -1; 1279 dictsFI = -1; 1280 dictsDR = false; 1281 contList = p->contList; 1282 } 1283 1284 MovelistCand::~MovelistCand() { 1285 delete [] dicts; 1286 } 1287 1288 char MovelistCand::dictsget(char x, char y) { 1289 return dicts[x-mx + p->sizeX*(y-my)]; 1290 } 1291 1292 void MovelistCand::dictsset(char x, char y, char d) { 1293 dicts[x-mx + p->sizeX*(y-my)] = d; 1294 } 1295 1296 bool MovelistCand::in_relevant_region(char x, char y) { 1297 return (mx <= x && x < mx + p->sizeX && my <= y && y < my + p->sizeY); 1298 } 1299 1300 1267 1301 int Algo_movelist::search(PatternList& patternList, GameList& gl, SearchOptions& options) { 1268 1302 // FIXME progbar, variations!!! … … 1274 1308 int Wwins = 0; 1275 1309 1276 int movelimit = 1000; 1277 int showColorSwap = 1; 1278 // if (options.has_key('movelimit')) movelimit = options['movelimit']; 1279 // if (options.has_key('showcolorswap')) showColorSwap = options['showcolorswap']; 1310 int movelimit = options.moveLimit; 1280 1311 1281 1312 int index = gl.start(); … … 1312 1343 1313 1344 vector<Candidate* > *currentMatchList = gl.getCurrentCandidateList(); 1314 char_p* dicts = new char_p[currentMatchList->size()]; 1315 int* dictsDR = new int[currentMatchList->size()]; 1316 int* dictsF = new int[currentMatchList->size()]; 1317 int* dictsFI = new int[currentMatchList->size()]; 1318 int* dictsPS = new int[currentMatchList->size()]; 1319 int* dictsNO = new int[currentMatchList->size()]; 1320 pair<char,char> *Xinterv = new pair<char,char>[currentMatchList->size()]; 1321 pair<char,char> *Yinterv = new pair<char,char>[currentMatchList->size()]; 1322 vector<MoveNC> *contList = new vector<MoveNC>[currentMatchList->size()]; 1323 int* contListIndex = new int[currentMatchList->size()]; 1345 vector<MovelistCand* > cands; 1346 cands.reserve(currentMatchList->size()); 1324 1347 1325 1348 for(int mCounter=0; mCounter<currentMatchList->size(); mCounter++) { … … 1336 1359 } 1337 1360 } 1338 1339 dicts[mCounter] = d; 1340 dictsPS[mCounter] = p->sizeX; 1341 dictsF[mCounter] = -1; 1342 dictsFI[mCounter] = -1; 1343 dictsDR[mCounter] = 0; 1344 dictsNO[mCounter] = dNO; 1345 1346 for (int i=0; i<p->lenContList; i++) { 1347 char x = p->contList[4*i]; 1348 char y = p->contList[4*i+1]; 1349 char color = p->contList[4*i+2]; 1350 contList[mCounter].push_back(MoveNC(x+m->x, y+m->y, color)); 1351 } 1352 contListIndex[mCounter] = 0; 1353 Xinterv[mCounter] = pair<char,char>(m->x, m->x + p->sizeX); 1354 Yinterv[mCounter] = pair<char,char>(m->y, m->y + p->sizeY); 1361 cands.push_back(new MovelistCand(p, m->orientation, d, dNO, m->x, m->y)); 1355 1362 } 1356 1363 … … 1373 1380 // Pattern p = patternList.get(m[0]); // FIXME: besser pointer uebergeben? 1374 1381 // if (p.colorSwitch) numOfSwitched++; 1375 // if (p.colorSwitch && showColorSwap)1382 // if (p.colorSwitch) 1376 1383 // result->append((dicts[m]['found'], '-')); 1377 1384 // else result->append((dicts[m]['found'], '')); … … 1404 1411 } 1405 1412 1406 for(int mCounter=0; mCounter<currentMatchList->size(); mCounter++) { 1407 if (!dicts[mCounter]) continue; 1408 Candidate* m = (*currentMatchList)[mCounter]; 1409 if (Xinterv[mCounter].first <= x && x < Xinterv[mCounter].second && \ 1410 Yinterv[mCounter].first <= y && y < Yinterv[mCounter].second) { 1411 if (dictsF[mCounter] != -1) { // found, so now we have found the continuation 1413 for(vector<MovelistCand* >::iterator it = cands.begin(); it != cands.end(); it++) { 1414 if (*it == 0) continue; 1415 if ((*it)->in_relevant_region(x,y)) { 1416 if ((*it)->dictsF != -1) { // found, so now we have found the continuation 1412 1417 char* label; 1413 1418 label = patternList.updateContinuations( 1414 m->orientation, // pattern in question1415 x- Xinterv[mCounter].first, y-Yinterv[mCounter].first, // pos of continuation1419 (*it)->orientation, // pattern in question 1420 x-(*it)->mx, y-(*it)->my, // pos of continuation 1416 1421 invco, // color of continuation 1417 (counter- dictsF[mCounter])>2, // tenuki?1422 (counter-(*it)->dictsF)>2, // tenuki? 1418 1423 gl.getCurrentWinner() 1419 1424 ); 1420 1425 if (!label) { // no hit because continuation has wrong color (i.e. nextMove set) 1421 delete [] dicts[mCounter];1422 dicts[mCounter]= 0;1426 delete *it; 1427 *it = 0; 1423 1428 continue; 1424 1429 } … … 1426 1431 numOfSwitched += label[2]; 1427 1432 1428 result->push_back(new Hit(new ExtendedMoveNumber( dictsF[mCounter]), label));1429 delete [] dicts[mCounter];1430 dicts[mCounter]= 0;1433 result->push_back(new Hit(new ExtendedMoveNumber((*it)->dictsF), label)); 1434 delete *it; 1435 *it = 0; 1431 1436 continue; 1432 } else if ( dictsFI[mCounter]!= -1) { // foundInitial, so now look for contList1433 if (MoveNC(x, y, co) == ( contList[mCounter])[contListIndex[mCounter]]) {1434 contListIndex[mCounter]++;1435 if ( contListIndex[mCounter] == contList[mCounter].size()) {1436 dictsF[mCounter]= counter;1437 } else if ((*it)->dictsFI != -1) { // foundInitial, so now look for contList 1438 if (MoveNC(x, y, co) == ((*it)->contList)[(*it)->contListIndex]) { 1439 (*it)->contListIndex++; 1440 if ((*it)->contListIndex == (*it)->contList.size()) { 1441 (*it)->dictsF = counter; 1437 1442 } 1438 1443 } else { 1439 if (dictsDR[mCounter]) { // don't restore 1440 if (dicts[mCounter]) delete [] dicts[mCounter]; 1441 else printf("OUCH\n"); 1442 dicts[mCounter] = 0; 1444 if ((*it)->dictsDR) { // don't restore 1445 delete *it; 1446 *it = 0; 1443 1447 continue; 1444 1448 } else { 1445 contListIndex[mCounter]= 0;1446 dictsFI[mCounter]= -1;1449 (*it)->contListIndex = 0; 1450 (*it)->dictsFI = -1; 1447 1451 } 1448 1452 } 1449 1453 } 1450 1454 1451 if (! dicts[mCounter][x-m->x + dictsPS[mCounter]*(y-m->y)]) { // this move occupies a spot which should be empty1455 if (!(*it)->dictsget(x,y)) { // this move occupies a spot which should be empty 1452 1456 if (!(fpC[y/4 + 5*(x/2)] & (1 << (x%2 + 2*(y%4))))) { 1453 if (!contListIndex[mCounter]) { 1454 if (dicts[mCounter]) delete [] dicts[mCounter]; 1455 else printf("OUCH\n"); 1456 dicts[mCounter] = 0; 1457 if (!(*it)->contListIndex) { 1458 delete *it; 1459 *it = 0; 1457 1460 continue; 1458 } else dictsDR[mCounter] = 1;1461 } else (*it)->dictsDR = true; 1459 1462 } else { 1460 dicts[mCounter][x-m->x + dictsPS[mCounter]*(y-m->y)] = '.';1461 dictsNO[mCounter]++;1463 (*it)->dictsset(x,y,'.'); 1464 (*it)->dictsNO++; 1462 1465 } 1463 } else if ( dicts[mCounter][x-m->x + dictsPS[mCounter]*(y-m->y)]== lower_invco) {1464 // this move occupies a wildcard spot 1466 } else if ((*it)->dictsget(x,y) == lower_invco) { 1467 // this move occupies a wildcard spot of the wrong color 1465 1468 if (!(fpC[y/4 + 5*(x/2)] & (1 << (x%2 + 2*(y%4))))) { 1466 if (!contListIndex[mCounter]) { 1467 if (dicts[mCounter]) delete [] dicts[mCounter]; 1468 else printf("OUCH\n"); 1469 dicts[mCounter] = 0; 1469 if (!(*it)->contListIndex) { 1470 delete *it; 1471 *it = 0; 1470 1472 continue; 1471 } else dictsDR[mCounter] = 1;1472 } else dictsNO[mCounter]++;1473 } else if ( dicts[mCounter][x-m->x + dictsPS[mCounter]*(y-m->y)]== co) {1473 } else (*it)->dictsDR = true; 1474 } else (*it)->dictsNO++; 1475 } else if ((*it)->dictsget(x,y) == co) { 1474 1476 // this move gives us the stone we are looking for 1475 dicts[mCounter][x-m->x + dictsPS[mCounter]*(y-m->y)] = 0; 1476 dictsNO[mCounter]--; 1477 // printf("improvement %d\n", dictsNO[mCounter]); 1477 (*it)->dictsset(x,y,0); 1478 (*it)->dictsNO--; 1478 1479 } 1479 1480 } … … 1481 1482 } 1482 1483 else if (movel[movelistIndex+1] & REMOVE) { 1483 // printf("rmv\n");1484 1484 if (movel[movelistIndex+1] & BLACK) { 1485 1485 co = 'X'; … … 1488 1488 co = 'O'; 1489 1489 invco = 'X'; 1490 } else printf("oopsR?\n"); // FIXME 1491 1492 for (int mCounter = 0; mCounter < currentMatchList->size(); mCounter++) { 1493 if (!dicts[mCounter]) continue; 1494 Candidate* m = (*currentMatchList)[mCounter]; 1495 if (dictsF[mCounter] == -1) { // not found yet 1496 if (Xinterv[mCounter].first <= x && x < Xinterv[mCounter].second \ 1497 && Yinterv[mCounter].first <= y && y < Yinterv[mCounter].second) { 1498 if (dictsFI[mCounter] != -1) { // foundInitial 1499 int ii = contListIndex[mCounter]; 1500 while (ii < contList[mCounter].size() && contList[mCounter][ii].color == '-' && 1501 (x != contList[mCounter][ii].x || y != contList[mCounter][ii].y)) 1490 } 1491 1492 for(vector<MovelistCand* >::iterator it = cands.begin(); it != cands.end(); it++) { 1493 if (*it == 0) continue; 1494 if ((*it)->dictsF == -1) { // not found yet 1495 if ((*it)->in_relevant_region(x,y)) { 1496 if ((*it)->dictsFI != -1) { // foundInitial 1497 int ii = (*it)->contListIndex; 1498 while (ii < (*it)->contList.size() && (*it)->contList[ii].color == '-' && 1499 (x != (*it)->contList[ii].x || y != (*it)->contList[ii].y)) 1502 1500 ii++; 1503 if (ii < contList[mCounter].size() && contList[mCounter][ii].color == '-') {1504 MoveNC help = contList[mCounter][ii];1505 contList[mCounter][ii] = contList[mCounter][contListIndex[mCounter]];1506 contList[mCounter][contListIndex[mCounter]] = help;1507 1508 contListIndex[mCounter]++;1501 if (ii < (*it)->contList.size() && (*it)->contList[ii].color == '-') { 1502 MoveNC help = (*it)->contList[ii]; 1503 (*it)->contList[ii] = (*it)->contList[(*it)->contListIndex]; 1504 (*it)->contList[(*it)->contListIndex] = help; 1505 1506 (*it)->contListIndex++; 1509 1507 } else { 1510 if (dictsDR[mCounter]) { 1511 if (dicts[mCounter]) delete [] dicts[mCounter]; 1512 else printf("OUCH\n"); 1513 dicts[mCounter] = 0; 1508 if ((*it)->dictsDR) { 1509 delete *it; 1510 *it = 0; 1514 1511 continue; 1515 1512 } else { 1516 contListIndex[mCounter]= 0;1517 dictsFI[mCounter]= -1;1513 (*it)->contListIndex = 0; 1514 (*it)->dictsFI = -1; 1518 1515 } 1519 1516 } 1520 1517 } 1521 if (! dicts[mCounter][x-m->x + dictsPS[mCounter]*(y-m->y)]) {1518 if (!(*it)->dictsget(x,y)) { 1522 1519 // the stone at this position was what we needed, 1523 1520 // since it was captured, we are once again looking for it: 1524 dicts[mCounter][x-m->x + dictsPS[mCounter]*(y-m->y)] = co;1525 dictsNO[mCounter]++;1521 (*it)->dictsset(x,y,co); 1522 (*it)->dictsNO++; 1526 1523 } 1527 else if ( dicts[mCounter][x-m->x + dictsPS[mCounter]*(y-m->y)]== lower_invco) {1528 dictsNO[mCounter]--;1524 else if ((*it)->dictsget(x,y) == lower_invco) { 1525 (*it)->dictsNO--; 1529 1526 } 1530 else if (dicts[mCounter][x-m->x + dictsPS[mCounter]*(y-m->y)] == '.') { 1531 // we are looking for an empty spot here, so this capture 1532 // is helpful: 1533 dicts[mCounter][x-m->x + dictsPS[mCounter]*(y-m->y)] = 0; 1534 dictsNO[mCounter]--; 1527 else if ((*it)->dictsget(x,y) == '.') { 1528 &
