Changeset 186
- Timestamp:
- 09/29/06 21:00:39 (2 years ago)
- Files:
-
- 06/libkombilo/abstractboard.cc (modified) (5 diffs)
- 06/libkombilo/abstractboard.h (modified) (3 diffs)
- 06/libkombilo/cpptest.cc (modified) (2 diffs)
- 06/libkombilo/search.cc (modified) (36 diffs)
- 06/libkombilo/search.h (modified) (9 diffs)
- 06/libkombilo/setup.py (modified) (1 diff)
- 06/libkombilo/sgfparser.cc (modified) (3 diffs)
- 06/libkombilo/sgfparser.h (modified) (2 diffs)
- 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
r183 r186 62 62 } 63 63 64 Move& Move:: copy(const Move& m) {64 Move& Move::operator=(const Move& m) { 65 65 if (this != &m) { 66 66 x = m.x; … … 79 79 } 80 80 81 82 81 abstractBoard::abstractBoard(int bs) throw(BoardError) { 83 82 if (DEBUG_ABSTRACTBOARD) printf("AB::abstractBoard(int) 0\n"); … … 93 92 abstractBoard::abstractBoard(const abstractBoard& ab) { 94 93 if (DEBUG_ABSTRACTBOARD) printf("AB::abstractBoard(abstractBoard) 0\n"); 95 printf("copy constructor\n");96 94 boardsize = ab.boardsize; 97 95 status = new char[boardsize*boardsize+1]; … … 103 101 } 104 102 103 abstractBoard& 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 105 118 abstractBoard::~abstractBoard() { 106 119 if (DEBUG_ABSTRACTBOARD) printf("AB::~abstractBoard 0\n"); … … 109 122 } 110 123 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 // } 126 139 127 140 char abstractBoard::getStatus(int x, int y) { 06/libkombilo/abstractboard.h
r183 r186 56 56 Move(const Move& m); 57 57 ~Move(); 58 Move& copy(const Move& m);58 Move& operator=(const Move& m); 59 59 60 60 vector<pair<char,char> >* captures; … … 71 71 abstractBoard(const abstractBoard& ab); 72 72 ~abstractBoard(); 73 //abstractBoard& operator=(const abstractBoard& ab);73 abstractBoard& operator=(const abstractBoard& ab); 74 74 void clear(); 75 75 int play(int x, int y, char* color) throw(BoardError); … … 80 80 int len_cap_last() throw(BoardError); 81 81 void undostack_append_pass(); 82 abstractBoard& copy(const abstractBoard& ab);82 // abstractBoard& copy(const abstractBoard& ab); 83 83 84 84 private: 06/libkombilo/cpptest.cc
r184 r186 6 6 using namespace boost::filesystem; 7 7 8 int main( ) {8 int main(int argc, char** argv) { 9 9 GameList gl("t1.db", "id", "[[PW]] - [[PB]] ([[winner]]), [[filename.]]", ALGO_FINALPOS | ALGO_MOVELIST | ALGO_HASH_FULL, 19); 10 10 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()); 12 23 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()); 26 32 } 27 infile.close();28 gl.process(sgf.c_str(), path.c_str(), n.c_str());29 33 } 34 gl.finalize_processing(); 35 printf("Processed %d games.\n", gl.size()); 30 36 } 31 gl.finalize_processing(); 32 printf("Processed %d games.\n", gl.size()); 37 printf("%d games.\n", gl.size()); 33 38 34 39 // 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") ; 36 41 // vector<MoveNC> contList; 37 42 // contList.push_back(MoveNC(6,15,'X')); … … 39 44 // contList.push_back(MoveNC(4,15,'X')); 40 45 // 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............."); 41 47 SearchOptions so; 48 // so.searchInVariations = false; 42 49 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()); 47 54 } 06/libkombilo/search.cc
r185 r186 772 772 Algo_signature::Algo_signature(int bsize) : Algorithm(bsize) { 773 773 datasig = 0; 774 main_variation = true; 774 775 } 775 776 … … 787 788 788 789 void Algo_signature::newgame_process(int game_id) { 790 main_variation = true; 789 791 counter = 0; 790 792 gid = game_id; … … 806 808 807 809 void Algo_signature::move_process(Move m) { 810 if (!main_variation) return; 808 811 counter++; 809 812 … … 835 838 836 839 void Algo_signature::pass_process() { 837 move_process(Move(19,19,'p'));840 if (main_variation) move_process(Move(19,19,'p')); 838 841 } 839 842 … … 843 846 844 847 void Algo_signature::endOfVariation_process() { 848 main_variation = false; 845 849 } 846 850 … … 1277 1281 dictsNO = NO; 1278 1282 contListIndex = 0; 1279 dictsF = -1;1280 dictsF I = -1;1283 dictsFound = false; 1284 dictsFoundInitial = false; 1281 1285 dictsDR = false; 1282 contList = p->contList; 1286 contList = p->contList; // FIXME 1283 1287 } 1284 1288 … … 1300 1304 1301 1305 1306 VecMC::VecMC() : vector<MovelistCand* >() { 1307 candssize = 0; 1308 } 1309 1310 VecMC::~VecMC() { 1311 for(VecMC::iterator it = begin(); it != end(); it++) { 1312 if (*it) delete *it; 1313 } 1314 } 1315 1316 VecMC* 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 1302 1340 int Algo_movelist::search(PatternList& patternList, GameList& gl, SearchOptions& options) { 1303 // FIXME progbar , variations!!!1341 // FIXME progbar 1304 1342 1305 1343 // printf("Enter Algo_movelist::search\n"); … … 1324 1362 vector<Hit* > * result = new vector<Hit* >; 1325 1363 int numOfSwitched = 0; 1326 // branchpoints = [];1364 stack<VecMC* > branchpoints; 1327 1365 1328 1366 char* movel = (*data1)[index-1]; … … 1332 1370 // int nodeCtr = 0; 1333 1371 // 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"); 1334 1374 // if (movel[2*i+1] & BLACK) printf("B"); 1335 1375 // if (movel[2*i+1] & WHITE) printf("W"); … … 1344 1384 1345 1385 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()); 1348 1389 1349 1390 for(int mCounter=0; mCounter<currentMatchList->size(); mCounter++) { … … 1360 1401 } 1361 1402 } 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)); 1363 1404 } 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?! 1394 1460 1395 1461 char x = movel[movelistIndex] & 31; … … 1412 1478 } 1413 1479 1414 for(vector<MovelistCand* >::iterator it = cands .begin(); it != cands.end(); it++) {1480 for(vector<MovelistCand* >::iterator it = cands->begin(); it != cands->end(); it++) { 1415 1481 if (*it == 0) continue; 1416 1482 if ((*it)->in_relevant_region(x,y)) { 1417 if ((*it)->dictsF != -1) { // found, so now we have found the continuation1483 if ((*it)->dictsFound) { // found, so now we have found the continuation 1418 1484 char* label; 1419 1485 label = patternList.updateContinuations( … … 1421 1487 x-(*it)->mx, y-(*it)->my, // pos of continuation 1422 1488 invco, // color of continuation 1423 (counter -(*it)->dictsF)>2, // tenuki?1489 (counter.total_move_num()-(*it)->dictsF.total_move_num())>2, // tenuki? 1424 1490 gl.getCurrentWinner() 1425 1491 ); 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)); 1430 1495 } 1431 1496 1432 numOfSwitched += label[2];1433 1434 result->push_back(new Hit(new ExtendedMoveNumber((*it)->dictsF), label));1435 1497 delete *it; 1436 1498 *it = 0; 1499 candssize--; 1437 1500 continue; 1438 } else if ((*it)->dictsF I != -1) { // foundInitial, so now look for contList1501 } else if ((*it)->dictsFoundInitial) { // foundInitial, so now look for contList 1439 1502 if (MoveNC(x, y, co) == ((*it)->contList)[(*it)->contListIndex]) { 1440 1503 (*it)->contListIndex++; 1441 1504 if ((*it)->contListIndex == (*it)->contList.size()) { 1442 1505 (*it)->dictsF = counter; 1506 (*it)->dictsFound = true; 1443 1507 } 1444 1508 } else { … … 1446 1510 delete *it; 1447 1511 *it = 0; 1512 candssize--; 1448 1513 continue; 1449 1514 } else { 1450 1515 (*it)->contListIndex = 0; 1451 (*it)->dictsF I = -1;1516 (*it)->dictsFoundInitial = false; 1452 1517 } 1453 1518 } … … 1459 1524 delete *it; 1460 1525 *it = 0; 1526 candssize--; 1461 1527 continue; 1462 1528 } else (*it)->dictsDR = true; … … 1471 1537 delete *it; 1472 1538 *it = 0; 1539 candssize--; 1473 1540 continue; 1474 1541 } else (*it)->dictsDR = true; … … 1491 1558 } 1492 1559 1493 for(vector<MovelistCand* >::iterator it = cands .begin(); it != cands.end(); it++) {1560 for(vector<MovelistCand* >::iterator it = cands->begin(); it != cands->end(); it++) { 1494 1561 if (*it == 0) continue; 1495 if ( (*it)->dictsF == -1) { // not found yet1562 if (!(*it)->dictsFound) { // not found yet 1496 1563 if ((*it)->in_relevant_region(x,y)) { 1497 if ((*it)->dictsF I != -1) { // foundInitial1564 if ((*it)->dictsFoundInitial) { // foundInitial 1498 1565 int ii = (*it)->contListIndex; 1499 1566 while (ii < (*it)->contList.size() && (*it)->contList[ii].color == '-' && … … 1510 1577 delete *it; 1511 1578 *it = 0; 1579 candssize--; 1512 1580 continue; 1513 1581 } else { 1514 1582 (*it)->contListIndex = 0; 1515 (*it)->dictsF I = -1;1583 (*it)->dictsFoundInitial = false; 1516 1584 } 1517 1585 } … … 1537 1605 1538 1606 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++) { 1541 1609 if (*it == 0) continue; 1542 if (!(*it)->dictsNO && (*it)->dictsF==-1) {1610 if (!(*it)->dictsNO && !(*it)->dictsFound) { 1543 1611 if (!(*it)->contList.size()) { 1544 1612 (*it)->dictsF = counter; 1545 } else if ((*it)->dictsFI==-1) { 1613 (*it)->dictsFound = true; 1614 } else if (!(*it)->dictsFoundInitial) { 1546 1615 (*it)->dictsFI = counter; 1616 (*it)->dictsFoundInitial = true; 1547 1617 } else if (!(*it)->dictsDR) { // found initial position again during processing of contList 1548 printf("hi there\n");1549 1618 char* d = new char[(*it)->p->sizeX*(*it)->p->sizeY]; 1550 1619 for (int ct=0; ct < (*it)->p->sizeX*(*it)->p->sizeY; ct++) d[ct] = (*it)->dicts[ct]; 1551 1620 MovelistCand* mlc = new MovelistCand((*it)->p, (*it)->orientation, d, 0, (*it)->mx, (*it)->my); 1552 1621 mlc->dictsFI = counter; 1553 cands.push_back(mlc); 1622 cands->push_back(mlc); 1623 candssize++; 1554 1624 } 1555 1625 } 1556 1626 } 1557 counter ++;1627 counter.next(); 1558 1628 } 1559 1629 1560 // if (dicts=={} && !self.branchpoints) break;1630 if (candssize==0 && branchpoints.size()==0) break; 1561 1631 movelistIndex += 2; 1562 1632 } … … 1565 1635 1566 1636 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++) { 1568 1638 if (*it == 0) continue; 1569 if ((*it)->dictsF >= 0) {1639 if ((*it)->dictsFound) { 1570 1640 if ((*it)->p->colorSwitch) { 1571 1641 numOfSwitched++; … … 1600 1670 } else delete result; 1601 1671 index = gl.next(); 1602 for(vector<MovelistCand* >::iterator it = cands.begin(); it != cands.end(); it++) 1603 if (*it) delete *it; 1672 delete cands; 1604 1673 } 1605 1674 return 0; … … 1730 1799 11815752235866582LL }; 1731 1800 1801 HashVarInfo::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 1732 1811 1733 1812 Algo_hash::Algo_hash(int bsize) : Algorithm(bsize) { 1813 branchpoints = 0; 1734 1814 } 1735 1815 … … 1738 1818 1739 1819 int Algo_hash::insert_hash(long long hashCode, ExtendedMoveNumber& mn, Move* continuation) { 1820 // printf("insert %lld\n", hashCode); 1740 1821 char* buf = new char[30 + mn.length*2]; 1741 1822 if (continuation) { … … 1785 1866 currentHashCode = 0; // start with empty board 1786 1867 lfc = new vector<pair<long long, ExtendedMoveNumber>* >; 1787 // branchpoints = []; FIXME1868 branchpoints = new stack<HashVarInfo>; 1788 1869 } 1789 1870 … … 1851 1932 1852 1933 void Algo_hash::branchpoint_process() { 1853 // FIXME 1934 branchpoints->push(HashVarInfo(currentHashCode, lfc, moveNumber)); 1935 // printf("push %lld\n", currentHashCode); 1854 1936 } 1855 1937 1856 1938 void 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(); 1858 1951 } 1859 1952 … … 1862 1955 Move* continuation = 0; 1863 1956 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 1865 1958 delete *it; 1866 1959 } 1867 1960 delete lfc; 1868 1961 delete moveNumber; 1962 delete branchpoints; 1869 1963 } 1870 1964 … … 2458 2552 2459 2553 bool 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; 2461 2558 } 2462 2559 2463 2560 SearchOptions::SearchOptions() { 2464 2561 fixedColor = 0; 2465 moveLimit = 1000 ;2562 moveLimit = 10000; 2466 2563 nextMove = 0; 2467 2564 trustHashFull = 0; 2565 searchInVariations = true; 2468 2566 } 2469 2567 … … 2540 2638 format2 = "%2 - %3 (%W), %4"; 2541 2639 } else { 2542 char buf[ 5];2640 char buf[10]; 2543 2641 numColumns = 2; 2544 2642 format1 = "id,re"; … … 2902 3000 2903 3001 2904 void GameList::start_processing() throw(DBError) { 3002 void GameList::start_processing(int PROCESSVARIATIONS) throw(DBError) { 3003 processVariations = PROCESSVARIATIONS; 2905 3004 readDBs = 0; 2906 3005 int rc = sqlite3_open(dbname, &db); … … 3067 3166 for(int i=0; i<15; i++) { 3068 3167 rc = sqlite3_bind_text(ppStmt, i+5, rootNodeProperties[i], -1, SQLITE_TRANSIENT); 3168 delete [] rootNodeProperties[i]; 3069 3169 if (rc != SQLITE_OK) throw DBError(); 3070 3170 } … … 3081 3181 // play through the game 3082 3182 3083 Node* current = root; 3084 int counter = -1; 3183 Node* currentN = root; 3085 3184 for(int a=0; a < 20; a++) if (algo_ps[a]) algo_ps[a]->newgame_process(game_id); 3086 3185 3087 3186 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 { 3093 3193 3094 3194 // parse current node, watch out for B, W, AB, AW, AE properties 3095 3195 3096 const char* s = current ->SGFstring.c_str();3196 const char* s = currentN->SGFstring.c_str(); 3097 3197 int lSGFstring = strlen(s); 3098 3198 int i = 0; … … 3100 3200 i++; 3101 3201 3102 if (i>=lSGFstring) { 3103 throw SGFError(); 3104 } 3105 if (s[i] != ';') { 3106 throw SGFError(); 3107 } 3202 if (i>=lSGFstring || s[i] != ';') throw SGFError(); 3108 3203 i++; 3109 3204 … … 3148 3243 } else if (s[i] == 't') { ; // allow passes, but do not record the
