Changeset 183

Show
Ignore:
Timestamp:
09/22/06 20:53:40 (2 years ago)
Author:
ug
Message:

Improved contList handling; improved format string handling; minor changes.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • 06/libkombilo/abstractboard.cc

    r177 r183  
    2626BoardError::BoardError() {} 
    2727 
    28 // coordinates used here: (1,1)-(19,19) 
     28MoveNC::MoveNC() { 
     29        x = -1; 
     30        y = -1; 
     31        color = ' '; 
     32
     33 
     34// coordinates used here: (1,1)-(19,19) FIXME what? 
    2935MoveNC::MoveNC(char X, char Y, char COLOR) { 
    3036        x = X; 
     
    3339} 
    3440 
    35 bool MoveNC::operator==(const MoveNC& mnc)
     41bool MoveNC::operator==(const MoveNC& mnc) const
    3642        if (x == mnc.x && y == mnc.y && color == mnc.color) return true; 
    3743        else return false; 
  • 06/libkombilo/abstractboard.h

    r177 r183  
    4646                char color; 
    4747 
     48                MoveNC(); 
    4849          MoveNC(char X, char Y, char COLOR); 
    49                 bool operator==(const MoveNC& mnc)
     50                bool operator==(const MoveNC& mnc) const
    5051}; 
    5152 
  • 06/libkombilo/cpptest.cc

    r182 r183  
    22 
    33int 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); 
    55        // gl.gisearch("pw = 'Hane Naoki'"); 
    66        // 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); 
    912        SearchOptions so; 
    10         gl.search(pl, so); 
     13        gl.search(p, so); 
    1114        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()); 
    1218} 
  • 06/libkombilo/libkombilo.i

    r177 r183  
    1616%include "abstractboard.h" 
    1717%include "search.h" 
     18%template(vectorMNC) vector<MoveNC>; 
    1819 
     20 
  • 06/libkombilo/search.cc

    r182 r183  
    136136  if (sizeX != p.sizeX || sizeY != p.sizeY) return 0; 
    137137  if (left != p.left || right != p.right || top != p.top || bottom != p.bottom) return 0;  
    138   // if (moveOne != p.moveOne) return 0; 
    139138  for(int i=0; i < sizeX*sizeY; i++) 
    140139    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; 
    143141  return 1; 
    144142} 
     
    163161  initialPos = 0; 
    164162  finalPos = 0; 
    165   contList = 0; 
    166163        flip = 0; 
    167164        colorSwitch = 0; 
     
    171168 
    172169 
    173 Pattern::Pattern(int type, int boardsize, int sX, int sY, 
    174                  char* iPos, char* cList, int lenCList, char mOne) { 
     170Pattern::Pattern(int type, int boardsize, int sX, int sY, char* iPos) { 
    175171  flip = 0; 
    176172  colorSwitch = 0; 
    177   if (mOne=='B' || mOne=='X') moveOne = 'X'; 
    178   else moveOne = 'O'; 
    179   if (moveOne == 'X') moveTwo = 'O'; 
    180   else moveTwo = 'X'; 
    181173  sizeX = sX; 
    182174  sizeY = sY; 
     
    221213    finalPos[i] = iPos[i]; 
    222214  } 
    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 
     217Pattern::Pattern(int type, int boardsize, int sX, int sY, 
     218                 char* iPos, vector<MoveNC> CONTLIST) { 
    235219  flip = 0; 
    236220  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  
    247221  sizeX = sX; 
    248222  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        } 
    249256 
    250257  initialPos = new char[sizeX * sizeY]; 
     
    255262  } 
    256263 
    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 
     267Pattern::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]; 
    262285  } 
    263   contList[lenCList*4] = 0; 
     286 
     287        contList = CONTLIST; 
    264288} 
    265289 
     
    267291  if (initialPos) delete [] initialPos; 
    268292  if (finalPos) delete [] finalPos; 
    269   if (contList) delete [] contList; 
    270293} 
    271294 
     
    279302  flip = p.flip; 
    280303  colorSwitch = p.colorSwitch; 
    281   moveOne = p.moveOne; 
    282   moveTwo = p.moveTwo; 
    283304 
    284305  initialPos = new char[sizeX*sizeY]; 
     
    288309    finalPos[i] = p.finalPos[i]; 
    289310  } 
    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; 
    296312} 
    297313 
     
    306322    flip = p.flip; 
    307323    colorSwitch = p.colorSwitch; 
    308     moveOne = p.moveOne; 
    309     moveTwo = p.moveTwo; 
    310324 
    311325    if (initialPos) delete [] initialPos; 
    312326    if (finalPos) delete [] finalPos; 
    313     if (contList) delete [] contList; 
    314327     
    315328    initialPos = new char[sizeX*sizeY]; 
     
    319332      finalPos[i] = p.finalPos[i]; 
    320333    } 
    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; 
    326335  } 
    327336  return *this; 
     
    339348    flip = p.flip; 
    340349    colorSwitch = p.colorSwitch; 
    341     moveOne = p.moveOne; 
    342     moveTwo = p.moveTwo; 
    343350 
    344351    if (initialPos) delete [] initialPos; 
    345352    if (finalPos) delete [] finalPos; 
    346     if (contList) delete [] contList; 
    347353     
    348354    initialPos = new char[sizeX*sizeY]; 
     
    352358      finalPos[i] = p.finalPos[i]; 
    353359    } 
    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; 
    358361  } 
    359362  return *this; 
     
    473476    } 
    474477 
    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)); 
    483485    } 
    484     newContList[pattern.lenContList*4] = 0; 
    485486 
    486487    Pattern pNew(newLeft, newRight, newTop, newBottom, newSizeX, newSizeY, 
    487                  newInitialPos, newContList, pattern.lenContList, pattern.moveOne); 
     488                 newInitialPos, newContList); 
    488489 
    489490    pNew.flip = f; 
     
    491492 
    492493    delete [] newInitialPos; 
    493     delete [] newContList; 
    494494 
    495495    vector<Pattern>::iterator it; 
     
    513513        } 
    514514      } 
    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 
    524524 
    525525                        // printf("new size %d %d", newSizeX, newSizeY); 
    526526      Pattern pNew1(newLeft, newRight, newTop, newBottom, newSizeX, newSizeY, 
    527                     newInitialPos, newContList, pattern.lenContList, pattern.moveTwo); 
     527                    newInitialPos, newContList); 
    528528      pNew1.flip = f; 
    529529      pNew1.colorSwitch = 1; 
    530530 
    531531      delete [] newInitialPos; 
    532       delete [] newContList; 
    533532 
    534533      if (!fixedColor) { 
     
    12651264} 
    12661265 
     1266 
     1267MovelistCand::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 
     1284MovelistCand::~MovelistCand() { 
     1285        delete [] dicts; 
     1286} 
     1287 
     1288char MovelistCand::dictsget(char x, char y) { 
     1289  return dicts[x-mx + p->sizeX*(y-my)]; 
     1290} 
     1291 
     1292void MovelistCand::dictsset(char x, char y, char d) { 
     1293  dicts[x-mx + p->sizeX*(y-my)] = d; 
     1294} 
     1295 
     1296bool 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 
    12671301int Algo_movelist::search(PatternList& patternList, GameList& gl, SearchOptions& options) {  
    12681302        // FIXME progbar, variations!!! 
     
    12741308        int Wwins = 0; 
    12751309 
    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; 
    12801311 
    12811312        int index = gl.start(); 
     
    13121343 
    13131344                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()); 
    13241347 
    13251348                for(int mCounter=0; mCounter<currentMatchList->size(); mCounter++) { 
     
    13361359                                } 
    13371360                        } 
    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)); 
    13551362                } 
    13561363 
     
    13731380                        //                               Pattern p = patternList.get(m[0]); // FIXME: besser pointer uebergeben? 
    13741381                        //                               if (p.colorSwitch) numOfSwitched++; 
    1375                         //                               if (p.colorSwitch && showColorSwap
     1382                        //                               if (p.colorSwitch
    13761383                        //                                       result->append((dicts[m]['found'], '-')); 
    13771384                        //                               else result->append((dicts[m]['found'], '')); 
     
    14041411                                } 
    14051412 
    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 
    14121417                                                        char* label; 
    14131418                                                        label = patternList.updateContinuations( 
    1414                                                                         m->orientation, // pattern in question 
    1415                   x-Xinterv[mCounter].first, y-Yinterv[mCounter].first, // pos of continuation 
     1419                                                                        (*it)->orientation, // pattern in question 
     1420                  x-(*it)->mx, y-(*it)->my, // pos of continuation 
    14161421                                                                invco, // color of continuation 
    1417                                                                         (counter-dictsF[mCounter])>2, // tenuki? 
     1422                                                                        (counter-(*it)->dictsF)>2, // tenuki? 
    14181423                                                                        gl.getCurrentWinner() 
    14191424                                                                        ); 
    14201425                                                        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; 
    14231428                                                                continue; 
    14241429                                                        } 
     
    14261431                                                        numOfSwitched += label[2]; 
    14271432 
    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; 
    14311436                                                        continue; 
    1432                                                 } else if (dictsFI[mCounter] != -1) { // foundInitial, so now look for contList 
    1433                                                         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; 
    14371442                                                                } 
    14381443                                                        } 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; 
    14431447                                                                        continue; 
    14441448                                                                } else { 
    1445                                                                         contListIndex[mCounter] = 0; 
    1446                                                                         dictsFI[mCounter] = -1; 
     1449                                                                        (*it)->contListIndex = 0; 
     1450                                                                        (*it)->dictsFI = -1; 
    14471451                                                                } 
    14481452                                                        } 
    14491453                                                } 
    14501454 
    1451                                                 if (!dicts[mCounter][x-m->x + dictsPS[mCounter]*(y-m->y)]) { // this move occupies a spot which should be empty 
     1455                                                if (!(*it)->dictsget(x,y)) { // this move occupies a spot which should be empty 
    14521456                                                        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; 
    14571460                                                                        continue; 
    1458                                                                 } else dictsDR[mCounter] = 1
     1461                                                                } else (*it)->dictsDR = true
    14591462                                                        } else { 
    1460                                                                 dicts[mCounter][x-m->x + dictsPS[mCounter]*(y-m->y)] = '.'
    1461                                                                 dictsNO[mCounter]++; 
     1463                                                                (*it)->dictsset(x,y,'.')
     1464                                                                (*it)->dictsNO++; 
    14621465                                                        } 
    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 
    14651468                                                        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; 
    14701472                                                                        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) { 
    14741476                                                        // 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--; 
    14781479                                                } 
    14791480                                        } 
     
    14811482                        } 
    14821483                        else if (movel[movelistIndex+1] & REMOVE) { 
    1483                                 // printf("rmv\n"); 
    14841484                                if (movel[movelistIndex+1] & BLACK) { 
    14851485                                        co = 'X'; 
     
    14881488                                        co = 'O'; 
    14891489                                        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)) 
    15021500                                                                        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++; 
    15091507                                                                } 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; 
    15141511                                                                                continue; 
    15151512                                                                        } else { 
    1516                                                                                 contListIndex[mCounter] = 0; 
    1517                                                                                 dictsFI[mCounter] = -1;  
     1513                                                                                (*it)->contListIndex = 0; 
     1514                                                                                (*it)->dictsFI = -1;  
    15181515                                                                        } 
    15191516                                                                } 
    15201517                                                        } 
    1521                                                         if (!dicts[mCounter][x-m->x + dictsPS[mCounter]*(y-m->y)]) {  
     1518                                                        if (!(*it)->dictsget(x,y)) {  
    15221519                                                                // the stone at this position was what we needed, 
    15231520                                                                // 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++; 
    15261523                                                        } 
    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--; 
    15291526                                                        } 
    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                                                            &