Changeset 186

Show
Ignore:
Timestamp:
09/29/06 21:00:39 (2 years ago)
Author:
ug
Message:

Finished search in games w/ variations.

Files:

Legend:

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

    r183 r186  
    6262} 
    6363 
    64 Move& Move::copy(const Move& m) { 
     64Move& Move::operator=(const Move& m) { 
    6565  if (this != &m) { 
    6666    x = m.x; 
     
    7979} 
    8080 
    81  
    8281abstractBoard::abstractBoard(int bs) throw(BoardError) { 
    8382  if (DEBUG_ABSTRACTBOARD) printf("AB::abstractBoard(int) 0\n"); 
     
    9392abstractBoard::abstractBoard(const abstractBoard& ab) { 
    9493  if (DEBUG_ABSTRACTBOARD) printf("AB::abstractBoard(abstractBoard) 0\n"); 
    95   printf("copy constructor\n"); 
    9694  boardsize = ab.boardsize; 
    9795  status = new char[boardsize*boardsize+1]; 
     
    103101} 
    104102 
     103abstractBoard& abstractBoard::operator=(const abstractBoard& ab) { 
     104  if (DEBUG_ABSTRACTBOARD) printf("AB::operator= 0\n"); 
     105  if (this != &ab) { 
     106                boardsize = ab.boardsize; 
     107                delete [] status; 
     108                status = new char[boardsize*boardsize+1]; 
     109                for (int i = 0; i < boardsize*boardsize; i++) 
     110                        status[i] = ab.status[i]; 
     111                status[boardsize*boardsize] = 0; 
     112                undostack = stack<Move>(ab.undostack); 
     113                if (DEBUG_ABSTRACTBOARD) printf("AB::abstractBoard(abstractBoard) 100\n"); 
     114        } 
     115        return *this; 
     116} 
     117 
    105118abstractBoard::~abstractBoard() { 
    106119  if (DEBUG_ABSTRACTBOARD) printf("AB::~abstractBoard 0\n"); 
     
    109122} 
    110123 
    111 abstractBoard& abstractBoard::copy(const abstractBoard& ab) { 
    112   if (DEBUG_ABSTRACTBOARD) printf("AB::copy 0\n"); 
    113   printf("copy assignment operator\n"); 
    114   if (this != &ab) { 
    115     delete status; 
    116     boardsize = ab.boardsize; 
    117     status = new char[boardsize*boardsize+1]; 
    118     for (int i = 0; i < boardsize*boardsize; i++) 
    119       status[i] = ab.status[i]; 
    120     status[boardsize*boardsize] = 0; 
    121     undostack = ab.undostack; 
    122   } 
    123   if (DEBUG_ABSTRACTBOARD) printf("AB::copy 100\n"); 
    124   return *this; 
    125 
     124// abstractBoard& abstractBoard::copy(const abstractBoard& ab) { 
     125//   if (DEBUG_ABSTRACTBOARD) printf("AB::copy 0\n"); 
     126//   printf("copy assignment operator\n"); 
     127//   if (this != &ab) { 
     128//     delete status; 
     129//     boardsize = ab.boardsize; 
     130//     status = new char[boardsize*boardsize+1]; 
     131//     for (int i = 0; i < boardsize*boardsize; i++) 
     132//       status[i] = ab.status[i]; 
     133//     status[boardsize*boardsize] = 0; 
     134//     undostack = ab.undostack; 
     135//   } 
     136//   if (DEBUG_ABSTRACTBOARD) printf("AB::copy 100\n"); 
     137//   return *this; 
     138//
    126139 
    127140char abstractBoard::getStatus(int x, int y) { 
  • 06/libkombilo/abstractboard.h

    r183 r186  
    5656                Move(const Move& m); 
    5757                ~Move(); 
    58                 Move& copy(const Move& m); 
     58                Move& operator=(const Move& m); 
    5959 
    6060                vector<pair<char,char> >* captures; 
     
    7171                abstractBoard(const abstractBoard& ab); 
    7272                ~abstractBoard(); 
    73                 // abstractBoard& operator=(const abstractBoard& ab); 
     73                abstractBoard& operator=(const abstractBoard& ab); 
    7474                void clear(); 
    7575                int play(int x, int y, char* color) throw(BoardError); 
     
    8080                int len_cap_last() throw(BoardError); 
    8181                void undostack_append_pass(); 
    82                 abstractBoard& copy(const abstractBoard& ab); 
     82                // abstractBoard& copy(const abstractBoard& ab); 
    8383 
    8484        private: 
  • 06/libkombilo/cpptest.cc

    r184 r186  
    66using namespace boost::filesystem; 
    77 
    8 int main() { 
     8int main(int argc, char** argv) { 
    99        GameList gl("t1.db", "id", "[[PW]] - [[PB]] ([[winner]]), [[filename.]]", ALGO_FINALPOS | ALGO_MOVELIST | ALGO_HASH_FULL, 19); 
    1010 
    11         gl.start_processing(); 
     11        if (argc>1 && !strcmp(argv[1], "-p")) { 
     12                gl.start_processing(); 
     13                directory_iterator end_itr; 
     14                // string path = "/home/ug/go/kombilo/06/libkombilo"; 
     15                string path = "/home/ug/go/gtl/reviews"; 
     16                // string path = "/home/ug/go/gogod06/1999"; 
     17                for(directory_iterator it(path); it != end_itr; ++it) { 
     18                        string n = it->string(); 
     19                        if (n.substr(n.size()-4) == ".sgf") { 
     20                                ifstream infile; 
     21                                printf("%s\n", n.c_str()); 
     22                                infile.open(it->native_file_string().c_str()); 
    1223 
    13         directory_iterator end_itr; 
    14         string path = "/home/ug/go/gogod06/1999"; 
    15         for(directory_iterator it(path); it != end_itr; ++it) { 
    16                 string n = it->string(); 
    17                 if (n.substr(n.size()-4) == ".sgf") { 
    18                         ifstream infile; 
    19                         infile.open(it->native_file_string().c_str()); 
    20  
    21                         string sgf; 
    22                         string line; 
    23                         while (!infile.eof()) { 
    24                                 getline(infile, line); 
    25                                 sgf += line; 
     24                                string sgf; 
     25                                string line; 
     26                                while (!infile.eof()) { 
     27                                        getline(infile, line); 
     28                                        sgf += line; 
     29                                } 
     30                                infile.close(); 
     31                                gl.process(sgf.c_str(), path.c_str(), n.c_str());    
    2632                        } 
    27                         infile.close(); 
    28                         gl.process(sgf.c_str(), path.c_str(), n.c_str());    
    2933                } 
     34                gl.finalize_processing(); 
     35                printf("Processed %d games.\n", gl.size()); 
    3036        } 
    31         gl.finalize_processing(); 
    32         printf("Processed %d games.\n", gl.size()); 
     37        printf("%d games.\n", gl.size()); 
    3338 
    3439        // gl.gisearch("pw = 'Hane Naoki'"); 
    35         Pattern p(CENTER_PATTERN, 19, 3, 5, ".X..OX.OX.OXOXO") ; 
     40        // Pattern p(CENTER_PATTERN, 19, 3, 5, ".X..OX.OX.OXOXO") ; 
    3641        // vector<MoveNC> contList; 
    3742        // contList.push_back(MoveNC(6,15,'X')); 
     
    3944        // contList.push_back(MoveNC(4,15,'X')); 
    4045        // 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); 
     46        Pattern p(FULLBOARD_PATTERN, 19, 19, 19, "..O.O....X...XXXXX.OOXO....OXO.XXOOOXOXXXXOO.OOXO.OXO..O..X.X..OOX,X.XO.O.....XOOOXOXX..XO......X.XOXXX..XXXO........XOX..XXOOXO.OOO.....OOXOXOO.O...XX...X..OXXOO.XOX........O..OX.,..X..X.....X...OX...X..........O....XXXO...XO...X...OOOXOOXX...X....O..OX.O..OX..........OXX....OX..OO..O.OOOOX..O.OX..XX..OOXXXOX.XOOX..X....XXXXXOX...OX.......X.O.XO............."); 
    4147        SearchOptions so; 
     48        // so.searchInVariations = false; 
    4249        gl.search(p, so); 
    43         printf("num games: %d\n", gl.size()); 
    44         vector<string> res = gl.currentEntriesAsStrings(); 
    45         for(vector<string>::iterator it = res.begin(); it != res.end(); it++) 
    46               printf("%s\n", it->c_str()); 
     50        printf("num games: %d, num hits: %d\n", gl.size(), gl.numHits()); 
     51        // vector<string> res = gl.currentEntriesAsStrings(); 
     52        // for(vector<string>::iterator it = res.begin(); it != res.end(); it++) 
     53        //    printf("%s\n", it->c_str()); 
    4754} 
  • 06/libkombilo/search.cc

    r185 r186  
    772772Algo_signature::Algo_signature(int bsize) : Algorithm(bsize) { 
    773773        datasig = 0; 
     774        main_variation = true; 
    774775} 
    775776 
     
    787788 
    788789void Algo_signature::newgame_process(int game_id) { 
     790        main_variation = true; 
    789791        counter = 0; 
    790792  gid = game_id; 
     
    806808 
    807809void Algo_signature::move_process(Move m) { 
     810        if (!main_variation) return; 
    808811        counter++; 
    809812 
     
    835838 
    836839void Algo_signature::pass_process() { 
    837         move_process(Move(19,19,'p')); 
     840        if (main_variation) move_process(Move(19,19,'p')); 
    838841} 
    839842 
     
    843846 
    844847void Algo_signature::endOfVariation_process() { 
     848        main_variation = false; 
    845849} 
    846850 
     
    12771281        dictsNO = NO; 
    12781282        contListIndex = 0; 
    1279         dictsF = -1
    1280         dictsFI = -1
     1283        dictsFound = false
     1284        dictsFoundInitial = false
    12811285        dictsDR = false; 
    1282         contList = p->contList; 
     1286        contList = p->contList; // FIXME 
    12831287} 
    12841288 
     
    13001304 
    13011305 
     1306VecMC::VecMC() : vector<MovelistCand* >() { 
     1307        candssize = 0; 
     1308} 
     1309 
     1310VecMC::~VecMC() { 
     1311        for(VecMC::iterator it = begin(); it != end(); it++) { 
     1312                if (*it) delete *it; 
     1313        } 
     1314} 
     1315 
     1316VecMC* VecMC::deepcopy(ExtendedMoveNumber& COUNTER, int CANDSSIZE) { 
     1317        VecMC* result = new VecMC; 
     1318        result->candssize = CANDSSIZE; 
     1319        result->counter = COUNTER; 
     1320        for(VecMC::iterator it = begin(); it != end(); it++) { 
     1321                MovelistCand* mlc = 0; 
     1322                if (*it) { 
     1323                        char* DICTS = new char[(*it)->p->sizeX * (*it)->p->sizeY]; 
     1324                        for (int i=0; i < (*it)->p->sizeX * (*it)->p->sizeY; i++) DICTS[i] = (*it)->dicts[i]; 
     1325                        mlc = new MovelistCand((*it)->p, (*it)->orientation, DICTS, (*it)->dictsNO, (*it)->mx, (*it)->my); 
     1326                        mlc->contListIndex = (*it)->contListIndex; 
     1327                        mlc->dictsFound = (*it)->dictsFound; 
     1328                        mlc->dictsF = (*it)->dictsF; 
     1329                        mlc->dictsFoundInitial = (*it)->dictsFoundInitial; 
     1330                        mlc->dictsFI = (*it)->dictsFI; 
     1331                        mlc->dictsDR = (*it)->dictsDR; 
     1332                        mlc->contList = mlc->p->contList; // FIXME 
     1333                } 
     1334                result->push_back(mlc); 
     1335        } 
     1336        return result; 
     1337} 
     1338 
     1339 
    13021340int Algo_movelist::search(PatternList& patternList, GameList& gl, SearchOptions& options) {  
    1303         // FIXME progbar, variations!!! 
     1341        // FIXME progbar 
    13041342 
    13051343        // printf("Enter Algo_movelist::search\n"); 
     
    13241362                vector<Hit* > * result = new vector<Hit* >; 
    13251363                int numOfSwitched = 0; 
    1326                 // branchpoints = []
     1364                stack<VecMC* > branchpoints
    13271365 
    13281366                char* movel = (*data1)[index-1]; 
     
    13321370                // int nodeCtr = 0; 
    13331371                // for(int i=0; i<endMovelist/2; i++) { 
     1372                //      if (movel[2*i] & BRANCHPOINT) printf("BP\n"); 
     1373                //      if (movel[2*i] & ENDOFVARIATION) printf("EV\n"); 
    13341374                //      if (movel[2*i+1] & BLACK) printf("B"); 
    13351375                //      if (movel[2*i+1] & WHITE) printf("W"); 
     
    13441384 
    13451385                vector<Candidate* > *currentMatchList = gl.getCurrentCandidateList(); 
    1346                 vector<MovelistCand* > cands; 
    1347                 cands.reserve(currentMatchList->size()); 
     1386                int candssize = currentMatchList->size(); 
     1387                VecMC* cands = new VecMC; 
     1388                cands->reserve(currentMatchList->size()); 
    13481389 
    13491390                for(int mCounter=0; mCounter<currentMatchList->size(); mCounter++) { 
     
    13601401                                } 
    13611402                        } 
    1362                         cands.push_back(new MovelistCand(p, m->orientation, d, dNO, m->x, m->y)); 
     1403                        cands->push_back(new MovelistCand(p, m->orientation, d, dNO, m->x, m->y)); 
    13631404                } 
    1364  
    1365                 int counter = 0; 
    1366  
    1367                 while (movelistIndex < endMovelist && counter <= movelimit) { 
    1368  
    1369                         // printf("counter %d\n", counter); 
    1370  
    1371                         // if (movel[movelistIndex] & BRANCHPOINT) { 
    1372                         //      self.branchpoints.append((deepcopy(dicts), deepcopy(dictsNO), 
    1373                         //                              deepcopy(contList), deepcopy(contListIndex), counter)); 
    1374                         //      movelistIndex += 2; 
    1375                         //      continue; 
    1376                         // } 
    1377                         // else if (movel[movelistIndex] & ENDOFVARIATION) { 
    1378                         //       if (!patternList.nextMove) { 
    1379                         //               for(m in dicts.keys()) 
    1380                         //                       if (dicts[m].has_key('found')) { 
    1381                         //                               Pattern p = patternList.get(m[0]); // FIXME: besser pointer uebergeben? 
    1382                         //                               if (p.colorSwitch) numOfSwitched++; 
    1383                         //                               if (p.colorSwitch) 
    1384                         //                                       result->append((dicts[m]['found'], '-')); 
    1385                         //                               else result->append((dicts[m]['found'], '')); 
    1386                         //                       } 
    1387                         //       } 
    1388                         //       dicts, dictsNO, contList, contListIndex, counter = self.branchpoints.pop(); 
    1389                         //       movelistIndex += 2; 
    1390                         //       continue; 
    1391                         // } 
    1392  
    1393                         int endOfNode = movel[movelistIndex] & ENDOFNODE; 
     1405                // printf("candssize %d\n", cands->size()); 
     1406 
     1407                ExtendedMoveNumber counter(0); 
     1408 
     1409                while (movelistIndex < endMovelist) { 
     1410                        if (counter.total_move_num() == movelimit+1) { 
     1411                                for(vector<MovelistCand* >::iterator it = cands->begin(); it != cands->end(); it++) { 
     1412                                        if (!(*it)->dictsFound) { 
     1413                                                delete *it; 
     1414                                                *it = 0; 
     1415                                                candssize--; 
     1416                                        } 
     1417                                } 
     1418                        } 
     1419                        if (options.searchInVariations && movel[movelistIndex] & BRANCHPOINT) { 
     1420                                // printf("branchpoint\n"); 
     1421                                branchpoints.push(cands->deepcopy(counter, candssize)); 
     1422                                movelistIndex += 2; 
     1423                                continue; 
     1424                        }  
     1425                        if (options.searchInVariations && movel[movelistIndex] & ENDOFVARIATION) { 
     1426                                // printf("endofvariation\n"); 
     1427                                if (!patternList.nextMove) { // deal with hits w/o continuation 
     1428                                        for(vector<MovelistCand* >::iterator it = cands->begin(); it != cands->end(); it++) { 
     1429                                                if (*it == 0) continue; 
     1430                                                if ((*it)->dictsFound) { 
     1431                                                        if ((*it)->p->colorSwitch) { 
     1432                                                                numOfSwitched++; 
     1433                                                                char* rstr = new char[3]; 
     1434                                                                rstr[0] = NO_CONT; 
     1435                                                                rstr[1] = 0; 
     1436                                                                rstr[2] = 1; 
     1437                                                                result->push_back(new Hit(new ExtendedMoveNumber((*it)->dictsF), rstr)); 
     1438                                                        } else { 
     1439                                                                char* rstr = new char[3]; 
     1440                                                                rstr[0] = NO_CONT; 
     1441                                                                rstr[1] = 0; 
     1442                                                                rstr[2] = 0; 
     1443                                                                result->push_back(new Hit(new ExtendedMoveNumber((*it)->dictsF), rstr)); 
     1444                                                        } 
     1445                                                } 
     1446                                        } 
     1447                                } 
     1448 
     1449                                delete cands; 
     1450                                cands = branchpoints.top(); 
     1451                                counter = cands->counter; 
     1452                                candssize = cands->candssize; 
     1453                                counter.down(); 
     1454                                branchpoints.pop(); 
     1455                                movelistIndex += 2; 
     1456                                continue; 
     1457                        } 
     1458 
     1459                        int endOfNode = movel[movelistIndex] & ENDOFNODE; // FIXME remove this variable?! 
    13941460 
    13951461                        char x = movel[movelistIndex] & 31; 
     
    14121478                                } 
    14131479 
    1414                                 for(vector<MovelistCand* >::iterator it = cands.begin(); it != cands.end(); it++) { 
     1480                                for(vector<MovelistCand* >::iterator it = cands->begin(); it != cands->end(); it++) { 
    14151481                                        if (*it == 0) continue; 
    14161482                                        if ((*it)->in_relevant_region(x,y)) { 
    1417                                                 if ((*it)->dictsF != -1) { // found, so now we have found the continuation 
     1483                                                if ((*it)->dictsFound) { // found, so now we have found the continuation 
    14181484                                                        char* label; 
    14191485                                                        label = patternList.updateContinuations( 
     
    14211487                  x-(*it)->mx, y-(*it)->my, // pos of continuation 
    14221488                                                                invco, // color of continuation 
    1423                                                                         (counter-(*it)->dictsF)>2, // tenuki? 
     1489                                                                        (counter.total_move_num()-(*it)->dictsF.total_move_num())>2, // tenuki? 
    14241490                                                                        gl.getCurrentWinner() 
    14251491                                                                        ); 
    1426                                                         if (!label) { // no hit because continuation has wrong color (i.e. nextMove set) 
    1427                                                                 delete *it; 
    1428                                                                 *it = 0; 
    1429                                                                 continue; 
     1492                                                        if (label) { // otherwise no hit because continuation has wrong color (i.e. nextMove set) 
     1493                                                                numOfSwitched += label[2]; 
     1494                                                                result->push_back(new Hit(new ExtendedMoveNumber((*it)->dictsF), label)); 
    14301495                                                        } 
    14311496 
    1432                                                         numOfSwitched += label[2]; 
    1433  
    1434                                                         result->push_back(new Hit(new ExtendedMoveNumber((*it)->dictsF), label)); 
    14351497                                                        delete *it; 
    14361498                                                        *it = 0; 
     1499                                                        candssize--; 
    14371500                                                        continue; 
    1438                                                 } else if ((*it)->dictsFI != -1) { // foundInitial, so now look for contList 
     1501                                                } else if ((*it)->dictsFoundInitial) { // foundInitial, so now look for contList 
    14391502                                                        if (MoveNC(x, y, co) == ((*it)->contList)[(*it)->contListIndex]) { 
    14401503                                                                (*it)->contListIndex++; 
    14411504                                                                if ((*it)->contListIndex == (*it)->contList.size()) { 
    14421505                                                                        (*it)->dictsF = counter; 
     1506                                                                        (*it)->dictsFound = true; 
    14431507                                                                } 
    14441508                                                        } else { 
     
    14461510                                                                        delete *it; 
    14471511                                                                        *it = 0; 
     1512                                                                        candssize--; 
    14481513                                                                        continue; 
    14491514                                                                } else { 
    14501515                                                                        (*it)->contListIndex = 0; 
    1451                                                                         (*it)->dictsFI = -1
     1516                                                                        (*it)->dictsFoundInitial = false
    14521517                                                                } 
    14531518                                                        } 
     
    14591524                                                                        delete *it; 
    14601525                                                                        *it = 0; 
     1526                                                                        candssize--; 
    14611527                                                                        continue; 
    14621528                                                                } else (*it)->dictsDR = true; 
     
    14711537                                                                        delete *it; 
    14721538                                                                        *it = 0; 
     1539                                                                        candssize--; 
    14731540                                                                        continue; 
    14741541                                                                } else (*it)->dictsDR = true; 
     
    14911558                                } 
    14921559 
    1493                                 for(vector<MovelistCand* >::iterator it = cands.begin(); it != cands.end(); it++) { 
     1560                                for(vector<MovelistCand* >::iterator it = cands->begin(); it != cands->end(); it++) { 
    14941561                                        if (*it == 0) continue; 
    1495                                         if ((*it)->dictsF == -1) { // not found yet 
     1562                                        if (!(*it)->dictsFound) { // not found yet 
    14961563                                                if ((*it)->in_relevant_region(x,y)) { 
    1497                                                         if ((*it)->dictsFI != -1) { // foundInitial 
     1564                                                        if ((*it)->dictsFoundInitial) { // foundInitial 
    14981565                                                                int ii = (*it)->contListIndex; 
    14991566                                                                while (ii < (*it)->contList.size() && (*it)->contList[ii].color == '-' && 
     
    15101577                                                                                delete *it; 
    15111578                                                                                *it = 0; 
     1579                                                                                candssize--; 
    15121580                                                                                continue; 
    15131581                                                                        } else { 
    15141582                                                                                (*it)->contListIndex = 0; 
    1515                                                                                 (*it)->dictsFI = -1;  
     1583                                                                                (*it)->dictsFoundInitial = false;  
    15161584                                                                        } 
    15171585                                                                } 
     
    15371605 
    15381606                        if (endOfNode) { 
    1539                                 vector<MovelistCand* >::iterator candsend = cands.end(); 
    1540                                 for(vector<MovelistCand* >::iterator it = cands.begin(); it != candsend; it++) { 
     1607                                vector<MovelistCand* >::iterator candsend = cands->end(); 
     1608                                for(vector<MovelistCand* >::iterator it = cands->begin(); it != candsend; it++) { 
    15411609                                        if (*it == 0) continue; 
    1542                                         if (!(*it)->dictsNO && (*it)->dictsF==-1) { 
     1610                                        if (!(*it)->dictsNO && !(*it)->dictsFound) { 
    15431611                                                if (!(*it)->contList.size()) { 
    15441612                                                        (*it)->dictsF = counter; 
    1545                                                 } else if ((*it)->dictsFI==-1) { 
     1613                                                        (*it)->dictsFound = true; 
     1614                                                } else if (!(*it)->dictsFoundInitial) { 
    15461615                                                        (*it)->dictsFI = counter; 
     1616                                                        (*it)->dictsFoundInitial = true; 
    15471617                                                } else if (!(*it)->dictsDR) { // found initial position again during processing of contList 
    1548                                                         printf("hi there\n"); 
    15491618                                                        char* d = new char[(*it)->p->sizeX*(*it)->p->sizeY]; 
    15501619                                                        for (int ct=0; ct < (*it)->p->sizeX*(*it)->p->sizeY; ct++) d[ct] = (*it)->dicts[ct]; 
    15511620                                                        MovelistCand* mlc = new MovelistCand((*it)->p, (*it)->orientation, d, 0, (*it)->mx, (*it)->my); 
    15521621                                                        mlc->dictsFI = counter; 
    1553                                                         cands.push_back(mlc); 
     1622                                                        cands->push_back(mlc); 
     1623                                                        candssize++; 
    15541624                                                } 
    15551625                                        } 
    15561626                                } 
    1557                                 counter++
     1627                                counter.next()
    15581628                        } 
    15591629 
    1560                         // if (dicts=={} && !self.branchpoints) break; 
     1630                        if (candssize==0 && branchpoints.size()==0) break; 
    15611631                        movelistIndex += 2; 
    15621632                } 
     
    15651635 
    15661636                if (!patternList.nextMove) { // look at matches w/o continuation 
    1567                         for(vector<MovelistCand* >::iterator it = cands.begin(); it != cands.end(); it++) { 
     1637                        for(vector<MovelistCand* >::iterator it = cands->begin(); it != cands->end(); it++) { 
    15681638                                if (*it == 0) continue; 
    1569                                 if ((*it)->dictsF >= 0) { 
     1639                                if ((*it)->dictsFound) { 
    15701640                                        if ((*it)->p->colorSwitch) { 
    15711641                                                numOfSwitched++; 
     
    16001670                } else delete result; 
    16011671                index = gl.next(); 
    1602                 for(vector<MovelistCand* >::iterator it = cands.begin(); it != cands.end(); it++) 
    1603                 if (*it) delete *it; 
     1672                delete cands; 
    16041673        } 
    16051674        return 0; 
     
    17301799        11815752235866582LL }; 
    17311800 
     1801HashVarInfo::HashVarInfo(long long CHC, vector<pair<long long, ExtendedMoveNumber>* > * LFC, 
     1802                                     ExtendedMoveNumber* MOVENUMBER) { 
     1803        chc = CHC; 
     1804        moveNumber = new ExtendedMoveNumber(*MOVENUMBER); 
     1805        lfc = new vector<pair<long long, ExtendedMoveNumber>* >; 
     1806        for(vector<pair<long long, ExtendedMoveNumber>* >::iterator it = LFC->begin(); it != LFC->end(); it++) { 
     1807                lfc->push_back(new pair<long long, ExtendedMoveNumber>((*it)->first, (*it)->second)); 
     1808        } 
     1809} 
     1810 
    17321811 
    17331812Algo_hash::Algo_hash(int bsize) : Algorithm(bsize) { 
     1813        branchpoints = 0; 
    17341814} 
    17351815 
     
    17381818 
    17391819int Algo_hash::insert_hash(long long hashCode, ExtendedMoveNumber& mn, Move* continuation) { 
     1820        // printf("insert %lld\n", hashCode); 
    17401821        char* buf = new char[30 + mn.length*2]; 
    17411822        if (continuation) { 
     
    17851866        currentHashCode = 0; // start with empty board 
    17861867        lfc = new vector<pair<long long, ExtendedMoveNumber>* >; 
    1787   // branchpoints = []; FIXME 
     1868  branchpoints = new stack<HashVarInfo>; 
    17881869} 
    17891870 
     
    18511932 
    18521933void Algo_hash::branchpoint_process() { 
    1853         // FIXME 
     1934        branchpoints->push(HashVarInfo(currentHashCode, lfc, moveNumber)); 
     1935        // printf("push %lld\n", currentHashCode); 
    18541936} 
    18551937 
    18561938void Algo_hash::endOfVariation_process() { 
    1857 //   poslist = self.branchpoints.pop(); FIXME 
     1939        for(vector<pair<long long, ExtendedMoveNumber>* >::iterator it = lfc->begin(); it != lfc->end(); it++) { 
     1940                int rc = insert_hash((*it)->first, (*it)->second, 0); 
     1941                if (rc != 0) printf("ouch %d\n", rc); // FIXME 
     1942                delete *it; 
     1943        } 
     1944        delete lfc; 
     1945        delete moveNumber; 
     1946  currentHashCode = branchpoints->top().chc; 
     1947        lfc = branchpoints->top().lfc; 
     1948        moveNumber = branchpoints->top().moveNumber; 
     1949        // printf("pop %lld\n", currentHashCode); 
     1950        branchpoints->pop(); 
    18581951} 
    18591952 
     
    18621955                Move* continuation = 0; 
    18631956                int rc = insert_hash((*it)->first, (*it)->second, continuation); 
    1864                 if (rc != 0) printf("ouch %d\n", rc); 
     1957                if (rc != 0) printf("ouch %d\n", rc); // FIXME 
    18651958                delete *it; 
    18661959        } 
    18671960        delete lfc; 
    18681961        delete moveNumber; 
     1962        delete branchpoints; 
    18691963} 
    18701964  
     
    24582552 
    24592553bool Hit::cmp_pts(Hit* a, Hit* b) { 
    2460         return a->pos->data[0] < b->pos->data[0]; // FIXME this must be improved for variations ... 
     2554        if (a->pos->length != b->pos->length) return a->pos->length < b->pos->length; 
     2555        for(int i=0; i < a->pos->length; i++) 
     2556                if (a->pos->data[i] != b->pos->data[i]) return a->pos->data[i] < b->pos->data[i]; 
     2557        return false; 
    24612558} 
    24622559 
    24632560SearchOptions::SearchOptions() { 
    24642561        fixedColor = 0; 
    2465         moveLimit = 1000
     2562        moveLimit = 10000
    24662563        nextMove = 0; 
    24672564        trustHashFull = 0; 
     2565        searchInVariations = true; 
    24682566} 
    24692567 
     
    25402638                format2 = "%2 - %3 (%W), %4"; 
    25412639        } else { 
    2542                 char buf[5]; 
     2640                char buf[10]; 
    25432641                numColumns = 2; 
    25442642                format1 = "id,re"; 
     
    29023000 
    29033001 
    2904 void GameList::start_processing() throw(DBError) { 
     3002void GameList::start_processing(int PROCESSVARIATIONS) throw(DBError) { 
     3003        processVariations = PROCESSVARIATIONS; 
    29053004        readDBs = 0; 
    29063005  int rc = sqlite3_open(dbname, &db);  
     
    30673166                for(int i=0; i<15; i++) { 
    30683167                        rc = sqlite3_bind_text(ppStmt, i+5, rootNodeProperties[i], -1, SQLITE_TRANSIENT);  
     3168                        delete [] rootNodeProperties[i]; 
    30693169                        if (rc != SQLITE_OK) throw DBError(); 
    30703170                } 
     
    30813181                // play through the game 
    30823182 
    3083                 Node* current = root; 
    3084                 int counter = -1; 
     3183                Node* currentN = root; 
    30853184                for(int a=0; a < 20; a++) if (algo_ps[a]) algo_ps[a]->newgame_process(game_id); 
    30863185 
    30873186                abstractBoard b = abstractBoard(boardsize); // BOARDSIZE?! 
    3088                 // NodeStack branchpoints(); 
    3089  
    3090                 try { 
    3091                         while (current) { 
    3092                                 counter++; 
     3187                int whichVar = 0; 
     3188                stack<VarInfo> branchpoints; 
     3189 
     3190                while (currentN) { 
     3191                        bool caughtSGFError = false; 
     3192                        try { 
    30933193 
    30943194                                // parse current node, watch out for B, W, AB, AW, AE properties 
    30953195 
    3096                                 const char* s = current->SGFstring.c_str(); 
     3196                                const char* s = currentN->SGFstring.c_str(); 
    30973197                                int lSGFstring = strlen(s); 
    30983198                                int i = 0; 
     
    31003200                                        i++; 
    31013201 
    3102                                 if (i>=lSGFstring) { 
    3103                                         throw SGFError(); 
    3104                                 } 
    3105                                 if (s[i] != ';') { 
    3106                                         throw SGFError(); 
    3107                                 } 
     3202                                if (i>=lSGFstring || s[i] != ';') throw SGFError(); 
    31083203                                i++; 
    31093204 
     
    31483243                                                        } else if (s[i] == 't') { ; // allow passes, but do not record the