Changeset 191

Show
Ignore:
Timestamp:
10/01/06 00:04:05 (2 years ago)
Author:
ug
Message:

Minor fixes (namespaces, Borland compatibility, sqlite_busy_timeout, ...).

Files:

Legend:

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

    r188 r191  
    2323 
    2424#include "abstractboard.h" 
     25using std::stack; 
     26using std::vector; 
    2527 
    2628BoardError::BoardError() {} 
  • 06/libkombilo/abstractboard.h

    r188 r191  
    2828#include <utility> 
    2929#include <stack> 
    30 using namespace std; 
    3130 
    3231const int DEBUG_ABSTRACTBOARD = 0; 
     
    3736}; 
    3837 
    39 typedef pair<char,char> p_cc; 
     38typedef std::pair<char,char> p_cc; 
    4039 
    4140 
     
    5857    Move& operator=(const Move& m); 
    5958 
    60     vector<pair<char,char> >* captures; 
     59    std::vector<p_cc >* captures; 
    6160}; 
    6261 
     
    6665    int boardsize; 
    6766    char* status; 
    68     stack<Move> undostack; 
     67    std::stack<Move> undostack; 
    6968 
    7069    abstractBoard(int bs = 19) throw(BoardError); 
     
    8483  private: 
    8584    int* neighbors(int x, int y); 
    86     vector<pair<char,char> >* legal(int x, int y, char color); 
    87     vector<pair<char,char> >* hasNoLibExcP(int x1, int y1, int exc=-1); 
     85    std::vector<p_cc >* legal(int x, int y, char color); 
     86    std::vector<p_cc >* hasNoLibExcP(int x1, int y1, int exc=-1); 
    8887    char invert(char); 
    8988}; 
  • 06/libkombilo/cpptest.cc

    r188 r191  
    44#include "search.h" 
    55 
    6 using namespace boost::filesystem; 
     6using namespace std; 
     7using boost::filesystem::directory_iterator; 
    78 
    89int main(int argc, char** argv) { 
  • 06/libkombilo/libkombilo.i

    r183 r191  
    1616%include "abstractboard.h" 
    1717%include "search.h" 
    18 %template(vectorMNC) vector<MoveNC>; 
     18%template(vectorMNC) std::vector<MoveNC>; 
    1919 
    2020 
  • 06/libkombilo/search.cc

    r190 r191  
    2828#include <string> 
    2929#include <cstring> 
     30 
     31using std::min; 
     32using std::max; 
     33using std::string; 
     34using std::vector; 
     35using std::pair; 
     36using std::make_pair; 
     37using std::stack; 
    3038 
    3139PatternError::PatternError() {} 
     
    93101} 
    94102 
    95 void Symmetries::set(char i, char j, char k, char l, char cs)
     103void Symmetries::set(char i, char j, char k, char l, char cs) throw(PatternError)
    96104  if (0 <= i && i < sizeX && 0 <= j && j < sizeY) { 
    97105    dataX[i + j*sizeX] = k; 
     
    99107    dataCS[i + j*sizeX] = cs; 
    100108  } 
    101   // else printf("Error Symmetries1\n"); // FIXME 
    102 } 
    103  
    104 char Symmetries::getX(char i, char j)
     109  else throw PatternError(); 
     110} 
     111 
     112char Symmetries::getX(char i, char j) throw(PatternError)
    105113  if (0 <= i && i < sizeX && 0 <= j && j < sizeY) return dataX[i + j*sizeX]; 
    106   else printf("Error Symmetries2\n"); // FIXME 
     114  else throw PatternError(); 
    107115  return -1; 
    108116} 
    109117 
    110 char Symmetries::getY(char i, char j)
     118char Symmetries::getY(char i, char j) throw(PatternError)
    111119  if (0 <= i && i < sizeX && 0 <= j && j < sizeY) return dataY[i + j*sizeX]; 
    112   else printf("Error Symmetries3\n"); // FIXME 
     120  else throw PatternError(); 
    113121  return -1; 
    114122} 
    115123 
    116 char Symmetries::getCS(char i, char j)
     124char Symmetries::getCS(char i, char j) throw(PatternError)
    117125  if (0 <= i && i < sizeX && 0 <= j && j < sizeY) return dataCS[i + j*sizeX]; 
    118   else printf("Error Symmetries4\n"); // FIXME 
     126  else throw PatternError(); 
    119127  return -1; 
    120128} 
    121129 
    122 char Symmetries::has_key(char i, char j)
     130char Symmetries::has_key(char i, char j) throw(PatternError)
    123131  if (0 <= i && i < sizeX && 0 <= j && j < sizeY) { 
    124132    if (dataX[i + j*sizeX] == -1) return 0; 
    125133    else return 1; 
    126134  } 
    127   else printf("Error Symmetries5\n"); // FIXME 
     135  else throw PatternError(); 
    128136  return 0; 
    129137} 
     
    363371} 
    364372 
    365 void Pattern::printPattern() { 
    366   printf("%d, %d, %d, %d\n", left, right, top, bottom); 
    367   printf("%d, %d\n", sizeX, sizeY); 
     373string Pattern::printPattern() { 
     374  string result; 
     375  char buf[40]; 
     376  sprintf(buf, "area: %d, %d, %d, %d\nsize: %d, %d\n", left, right, top, bottom, sizeX, sizeY); 
     377  result += buf; 
    368378  for(int i=0; i<sizeY; i++) { 
    369379    for(int j=0; j<sizeX; j++) { 
    370       if (initialPos[i*sizeX + j] == 'X') printf("X")
    371       else if (initialPos[i*sizeX + j] == 'O') printf("O")
    372       else printf("."); 
    373     } 
    374     printf("\n"); 
    375   } 
    376   printf("\n")
     380      if (initialPos[i*sizeX + j] == 'X' || initialPos[i*sizeX + j] == 'O' || initialPos[i*sizeX + j] == 'x' || initialPos[i*sizeX + j] == 'x' || initialPos[i*sizeX+j] == '*') result += initialPos[i*sizeX+j]
     381      else result += '.'
     382    } 
     383    result += "\n"; 
     384  } 
     385  result += "\n"; 
     386  return result
    377387} 
    378388 
     
    424434} 
    425435 
    426 PatternList::PatternList(const PatternList& pl) { 
    427   printf("OUCH. Copy constructor for PatternList needed.\n"); // FIXME 
    428 } 
    429  
    430 PatternList& PatternList::operator=(const PatternList& pl) { 
    431   printf("OUCH. operator= for PatternList needed.\n"); // FIXME 
    432   return *this; 
    433 } 
    434          
    435436char PatternList::invertColor(char co) { 
    436437  if (co == 'X') return 'O'; 
     
    631632 
    632633char* PatternList::updateContinuations(int index, int x, int y, char co, bool tenuki, char winner) { 
    633   // char* re = new char[3]; 
    634   // re[0] = 0; 
    635   // re[1] = 0; 
    636   // re[2] = 0; 
    637   // return re; 
    638    
    639634  char xx; 
    640635  char yy; 
     
    719714  sqlite3_stmt *ppStmt=0; 
    720715  int rc = sqlite3_prepare(db, sql, -1, &ppStmt, 0); 
    721   if (rc != SQLITE_OK || ppStmt==0) return rc; // FIXME: catch certain errors, (and/or throw DBError?) 
     716  if (rc != SQLITE_OK || ppStmt==0) return rc; 
    722717  rc = sqlite3_bind_int(ppStmt, 1, id); 
    723718  if (rc != SQLITE_OK) return rc; 
     
    734729  sqlite3_stmt *ppStmt=0; 
    735730  int rc = sqlite3_prepare(db, sql, -1, &ppStmt, 0); 
    736   if (rc != SQLITE_OK || ppStmt==0) return rc; // FIXME: catch certain errors, (and/or throw DBError?) 
     731  if (rc != SQLITE_OK || ppStmt==0) return rc; 
    737732  rc = sqlite3_bind_int(ppStmt, 1, id); 
    738733  if (rc != SQLITE_OK) return rc; 
     
    849844} 
    850845 
    851 void Algo_signature::endgame_process()
     846void Algo_signature::endgame_process() throw(DBError)
    852847  // symmetrize signature 
    853848  char* min_signature = new char[12]; 
     
    875870  } 
    876871  delete [] signature; 
    877   dbinsert1blob(db, "insert into algo_signature (id, signature) values (?,?);", gid, min_signature, 12); 
     872  if (dbinsert1blob(db, "insert into algo_signature (id, signature) values (?,?);", gid, min_signature, 12)) throw DBError(); 
    878873  // for(int i=0; i<12; i++) printf("%c", min_signature[i]); printf("\n"); 
    879874  delete [] min_signature; 
     
    940935} 
    941936 
    942 void Algo_finalpos::endgame_process()
    943   dbinsert1blob(db, "insert into algo_finalpos (id, data) values (?,?);", gid, fp, 100); 
     937void Algo_finalpos::endgame_process() throw(DBError)
     938  if (dbinsert1blob(db, "insert into algo_finalpos (id, data) values (?,?);", gid, fp, 100)) throw DBError(); 
    944939  delete [] fp; 
    945940} 
     
    12131208} 
    12141209 
    1215 void Algo_movelist::endgame_process()
     1210void Algo_movelist::endgame_process() throw(DBError)
    12161211  char* ml = new char[movelist.size()]; 
    12171212  int mlIndex = 0; 
     
    12191214    ml[mlIndex++] = *it; 
    12201215  } 
    1221   dbinsert2blobs(db, "insert into algo_movelist (id, movelist, fpC) values (?, ?, ?);", gid, ml, mlIndex, fpC, 50); 
     1216  if (dbinsert2blobs(db, "insert into algo_movelist (id, movelist, fpC) values (?, ?, ?);", gid, ml, mlIndex, fpC, 50)) throw DBError(); 
    12221217  delete [] ml; 
    12231218  delete [] fpC; 
     
    16721667} 
    16731668 
    1674  
    1675 const long long Algo_hash::hashCodes[] = { 
     1669#ifdef __BORLANDC__ 
     1670const hashtype Algo_hash::hashCodes[] = { 
     1671  1448047776469843i64 ,  23745670021858756i64 ,  2503503679898819i64 ,   
     1672  20893061577159209i64 ,  10807838381971450i64 ,  2362252468869198i64 ,   
     1673  24259008893265414i64 ,  12770534669822463i64 ,  6243872632612083i64 ,   
     1674  9878602848666731i64 ,  15403460661141300i64 ,  23328125617276831i64 ,   
     1675  24399618481479321i64 ,  6553504962910284i64 ,  1670313139184804i64 ,   
     1676  12980312942597170i64 ,  20479559860862969i64 ,  9622188310955879i64 ,   
     1677  240315181816498i64 ,  15806748501866401i64 ,  11025185739521454i64 ,   
     1678  9892014082139049i64 ,  24468178939325513i64 ,  18336761931886570i64 ,   
     1679  17607110247268341i64 ,  1659968630984898i64 ,  15644176636883129i64 ,   
     1680  21288430710467667i64 ,  21718647773405600i64 ,  8449573198599383i64 ,   
     1681  12949198458251018i64 ,  13260609204816340i64 ,  15942818511406502i64 ,   
     1682  19422389391992560i64 ,  2306873372585698i64 ,  13245768415868578i64 ,   
     1683  3527685889767840i64 ,  16821792770065498i64 ,  14659578113224043i64 ,   
     1684  8882299950073676i64 ,  7855747638699870i64 ,  11443553816792995i64 ,   
     1685  10278034782711378i64 ,  9888977721917330i64 ,  8622555585025384i64 , 
     1686  20622776792089008i64 ,  6447699412562541i64 ,  21593237574254863i64 , 
     1687  4100056509197325i64 ,  8358405560798101i64 ,  24120904895822569i64 , 
     1688  21004758159739407i64 ,  4380824971205155i64 ,  23810250238005035i64 , 
     1689  11573868012372637i64 ,  21740007761325076i64 ,  20569500166060069i64 , 
     1690  23367084743140030i64 ,  832128940274250i64 ,  3863567854976796i64 , 
     1691  8401188629788306i64 ,  20293444021869434i64 ,  12476938100997420i64 , 
     1692  5997141871489394i64 ,  777596196611050i64 ,  8407423122275781i64 , 
     1693  23742268390341663i64 ,  6606677504119583i64 ,  17099083579458611i64 , 
     1694  128040681345920i64 ,  7441253945309846i64 ,  17672412151152227i64 , 
     1695  14657002484427869i64 ,  3764334613856311i64 ,  7399928989161192i64 , 
     1696  24730167942169592i64 ,  13814924480574978i64 ,  5810810907567287i64 , 
     1697  7008927747711241i64 ,  3714629224790215i64 ,  9946435535599731i64 , 
     1698  20057491299504334i64 ,  15866852457019228i64 ,  123155262761331i64 , 
     1699  1315783062254243i64 ,  24497766846727950i64 ,  12902532251391440i64 , 
     1700  16788431106050494i64 ,  15993209359043506i64 ,  6163570598235227i64 , 
     1701  23479274902645580i64 ,  12086295521073246i64 ,  14074331278381816i64 , 
     1702  1049820141442769i64 ,  5160957003350972i64 ,  24302799572195320i64 , 
     1703  23881606652035662i64 ,  23969818184919245i64 ,  19374430422494128i64 , 
     1704  9346353622623467i64 ,  13646698673919768i64 ,  20787456987251805i64 , 
     1705  19834903548127921i64 ,  8194151691638546i64 ,  7687885124853709i64 , 
     1706  4843137186034754i64 ,  23141719256229263i64 ,  5528755394284040i64 , 
     1707  22362536622784133i64 ,  7624654257445620i64 ,  8792845080211956i64 , 
     1708  24991012676161170i64 ,  5382030845010972i64 ,  1942150054817210i64 , 
     1709  1024267612932772i64 ,  14257279792025309i64 ,  11127353401828247i64 , 
     1710  4123063511789286i64 ,  363215666444395i64 ,  15523634951795520i64 , 
     1711  21114031740764324i64 ,  12549698630972549i64 ,  7906682572409157i64 , 
     1712  9682658163949194i64 ,  14445831019902887i64 ,  19796086007848283i64 , 
     1713  25041651202294181i64 ,  434144873391024i64 ,  24468825775827696i64 , 
     1714  16436890395501393i64 ,  16373785289815135i64 ,  16626551488832360i64 , 
     1715  7748715007439309i64 ,  22731617567631698i64 ,  14232800365889972i64 , 
     1716  10951727445457549i64 ,  8041373240290953i64 ,  24930514145406896i64 , 
     1717  9591184974667554i64 ,  24880672410562956i64 ,  23221721160805093i64 , 
     1718  20593543181655919i64 ,  23599230930155014i64 ,  15520097083998302i64 , 
     1719  14424914931817466i64 ,  7073972177203460i64 ,  16674214483955582i64 , 
     1720  4557916889838393i64 ,  14520120252661131i64 ,  2948253205366287i64 , 
     1721  18549806070390636i64 ,  10409566723123418i64 ,  18398906015238963i64 , 
     1722  21169009649313417i64 ,  18391044531337716i64 ,  2911838512392375i64 , 
     1723  13771057876708721i64 ,  11955633853535396i64 ,  18911960208175147i64 , 
     1724  1483143365895487i64 ,  5864164841327281i64 ,  16798674080914657i64 , 
     1725  21169543712647072i64 ,  2554895121282201i64 ,  12465286616181485i64 , 
     1726  5756888636558955i64 ,  2597276631190750i64 ,  2560624395830604i64 , 
     1727  20296901708171088i64 ,  14642976680682096i64 ,  12194169777111940i64 , 
     1728  938262584370639i64 ,  7206443811292574i64 ,  501111636607822i64 , 
     1729  5705951146039127i64 ,  19098237626875269i64 ,  5726006303511723i64 , 
     1730  5717532750720198i64 ,  4848344546021481i64 ,  7407311808156422i64 , 
     1731  2061821731974308i64 ,  8556380079387133i64 ,  13575103943220600i64 , 
     1732  10594365938844562i64 ,  19966653780019989i64 ,  24412404083453688i64 , 
     1733  8019373982039936i64 ,  7753495706295280i64 ,  838015840877266i64 , 
     1734  5235642127051968i64 ,  10225916255867901i64 ,  14975561937408701i64 , 
     1735  4914762527221109i64 ,  16273933213731410i64 ,  25240707945233645i64 , 
     1736  6477894775523777i64 ,  16128190602024745i64 ,  12452291569329611i64 , 
     1737  51030855211419i64 ,  1848783942303739i64 ,  2537297571305471i64 , 
     1738  24811709277564335i64 ,  23354767332363093i64 ,  11338712562024830i64 , 
     1739  10845782284945582i64 ,  20710115514013598i64 ,  19611282767915684i64 , 
     1740  11160258605900113i64 ,  17875966449141620i64 ,  8400967803093668i64 , 
     1741  6871997953834029i64 ,  13914235659320051i64 ,  8949576634650339i64 , 
     1742  2143755776666584i64 ,  13309009078638265i64 ,  17871461210902733i64 , 
     1743  11987276750060947i64 ,  19212042799964345i64 ,  9684310155516547i64 , 
     1744  1307858104678668i64 ,  8369225045337652i64 ,  11470364009363081i64 , 
     1745  10726698770860164i64 ,  22857364846703600i64 ,  25284735055035435i64 , 
     1746  19224377054148393i64 ,  16403807100295998i64 ,  4653376186522389i64 , 
     1747  15242640882406966i64 ,  15315275662931969i64 ,  11642086728644568i64 , 
     1748  12158439227609947i64 ,  5366950703441186i64 ,  21989897136444615i64 , 
     1749  21241101455718813i64 ,  1591417368086590i64 ,  14579493634035095i64 , 
     1750  23329624772309429i64 ,  4022767503269837i64 ,  12858990365780377i64 , 
     1751  1546772101519453i64 ,  23839228242060485i64 ,  3152020333001361i64 , 
     1752  7700997223270546i64 ,  7886359803633970i64 ,  18794372628879385i64 , 
     1753  22159114735365084i64 ,  7999390508114986i64 ,  17413096555746886i64 , 
     1754  9385231705999634i64 ,  15875377080359488i64 ,  4319895571584052i64 , 
     1755  15831501864738265i64 ,  23927036136254152i64 ,  9023165779396619i64 , 
     1756  6131245054225200i64 ,  20314359892927215i64 ,  1896686091879468i64 , 
     1757  14130616725563771i64 ,  22653904323575475i64 ,  9831497463521490i64 , 
     1758  13110057076369419i64 ,  5902087517632052i64 ,  23714067728868348i64 , 
     1759  10422641883492326i64 ,  10327276345146850i64 ,  795518417987648i64 , 
     1760  25452954487907785i64 ,  3500196309207718i64 ,  14513995844064906i64 , 
     1761  7844549909962914i64 ,  9407804562184273i64 ,  15229768031797498i64 , 
     1762  14111656085687927i64 ,  16834184600349678i64 ,  7291182384885469i64 , 
     1763  17771577974633552i64 ,  21586473553657942i64 ,  18166326806718423i64 , 
     1764  10928317030329388i64 ,  13135712137024532i64 ,  12947681282864548i64 , 
     1765  21220312239923983i64 ,  9606249244876101i64 ,  4653965165819933i64 , 
     1766  5039148287631156i64 ,  3987726544496362i64 ,  11235885894214833i64 , 
     1767  3549024987193191i64 ,  6369560450327424i64 ,  5296536600431238i64 , 
     1768  10833371878822587i64 ,  5746338282416722i64 ,  20335144029844343i64 , 
     1769  14857534135172842i64 ,  13933887642921338i64 ,  3610489245941154i64 , 
     1770  7780064458218242i64 ,  18217608762631328i64 ,  4861734558486078i64 , 
     1771  19138089389909524i64 ,  162404484845663i64 ,  6326150309736266i64 , 
     1772  5691634479075905i64 ,  14377989390160001i64 ,  7788436404648140i64 , 
     1773  20312143630017606i64 ,  6781467023516504i64 ,  7265384191721189i64 , 
     1774  13990392558924592i64 ,  4811546322556989i64 ,  3891404257596968i64 , 
     1775  19222546653408634i64 ,  9733466771346453i64 ,  20011679489309705i64 , 
     1776  11556921572925005i64 ,  13429005557512149i64 ,  16680841455593148i64 , 
     1777  394589115298971i64 ,  22224576785554448i64 ,  18262625753524808i64 , 
     1778  20893780129453860i64 ,  25064972830160559i64 ,  241970110039610i64 , 
     1779  7452533933839720i64 ,  10726026396546933i64 ,  17312051917081899i64 , 
     1780  17281553837379637i64 ,  24008819488103387i64 ,  5193878516496164i64 , 
     1781  21529615734706496i64 ,  22844915602846365i64 ,  17118246686087168i64 , 
     1782  6560869056902581i64 ,  10553021967047717i64 ,  3729950813036887i64 , 
     1783  14459986099519295i64 ,  15808907290234758i64 ,  6234512969275540i64 , 
     1784  18690008075805909i64 ,  492531108753402i64 ,  7721002928884704i64 , 
     1785  4886156035126456i64 ,  21716374046066558i64 ,  11035311630511661i64 , 
     1786  16837692753538891i64 ,  20172053977953882i64 ,  15488511700491202i64 , 
     1787  17477921115358343i64 ,  24726937211646877i64 ,  22480504880004621i64 , 
     1788  18521326635500559i64 ,  8076560603417178i64 ,  22382516625473209i64 , 
     1789  21696842111535623i64 ,  12559160944089288i64 ,  1661142873895453i64 , 
     1790  18379772814447567i64 ,  10295321430586466i64 ,  12378145201769592i64 ,   
     1791  11815752235866582i64 }; 
     1792#else 
     1793const hashtype Algo_hash::hashCodes[] = { 
    16761794  1448047776469843LL ,  23745670021858756LL ,  2503503679898819LL ,   
    16771795  20893061577159209LL ,  10807838381971450LL ,  2362252468869198LL ,   
     
    17951913  18379772814447567LL ,  10295321430586466LL ,  12378145201769592LL ,   
    17961914  11815752235866582LL }; 
    1797  
    1798 HashVarInfo::HashVarInfo(long long CHC, vector<pair<long long, ExtendedMoveNumber>* > * LFC, 
     1915#endif 
     1916 
     1917HashVarInfo::HashVarInfo(hashtype CHC, vector<pair<hashtype, ExtendedMoveNumber>* > * LFC, 
    17991918                         ExtendedMoveNumber* MOVENUMBER) { 
    18001919  chc = CHC; 
    18011920  moveNumber = new ExtendedMoveNumber(*MOVENUMBER); 
    1802   lfc = new vector<pair<long long, ExtendedMoveNumber>* >; 
    1803   for(vector<pair<long long, ExtendedMoveNumber>* >::iterator it = LFC->begin(); it != LFC->end(); it++) { 
    1804     lfc->push_back(new pair<long long, ExtendedMoveNumber>((*it)->first, (*it)->second)); 
     1921  lfc = new vector<pair<hashtype, ExtendedMoveNumber>* >; 
     1922  for(vector<pair<hashtype, ExtendedMoveNumber>* >::iterator it = LFC->begin(); it != LFC->end(); it++) { 
     1923    lfc->push_back(new pair<hashtype, ExtendedMoveNumber>((*it)->first, (*it)->second)); 
    18051924  } 
    18061925} 
     
    18141933} 
    18151934 
    1816 int Algo_hash::insert_hash(long long hashCode, ExtendedMoveNumber& mn, Move* continuation) { 
     1935int Algo_hash::insert_hash(hashtype hashCode, ExtendedMoveNumber& mn, Move* continuation) { 
    18171936  // printf("insert %lld\n", hashCode); 
    18181937  char* buf = new char[30 + mn.length*2]; 
     
    18351954  sqlite3_stmt *ppStmt=0; 
    18361955  int rc = sqlite3_prepare(db, sql, -1, &ppStmt, 0); 
    1837   if (rc != SQLITE_OK || ppStmt==0) return rc; // FIXME: catch certain errors, (and/or throw DBError?) 
     1956  if (rc != SQLITE_OK || ppStmt==0) return rc; 
    18381957  rc = sqlite3_bind_int64(ppStmt, 1, currentHashCode); 
    18391958  if (rc != SQLITE_OK) return rc; 
     
    18621981  moveNumber = new ExtendedMoveNumber(0); 
    18631982  currentHashCode = 0; // start with empty board 
    1864   lfc = new vector<pair<long long, ExtendedMoveNumber>* >; 
     1983  lfc = new vector<pair<hashtype, ExtendedMoveNumber>* >; 
    18651984  branchpoints = new stack<HashVarInfo>; 
    18661985} 
    18671986 
    18681987void Algo_hash::AB_process(int x, int y) { 
    1869   for(vector<pair<long long, ExtendedMoveNumber>* >::iterator it = lfc->begin(); it != lfc->end(); it++) { 
     1988  for(vector<pair<hashtype, ExtendedMoveNumber>* >::iterator it = lfc->begin(); it != lfc->end(); it++) { 
    18701989    Move* continuation = new Move(x,y,'B'); 
    18711990    if (insert_hash((*it)->first, (*it)->second, continuation) != 0) throw DBError(); 
     
    18741993  } 
    18751994  delete lfc; 
    1876   lfc = new vector<pair<long long, ExtendedMoveNumber>* >; 
     1995  lfc = new vector<pair<hashtype, ExtendedMoveNumber>* >; 
    18771996  currentHashCode += hashCodes[x + boardsize*y]; 
    18781997} 
    18791998 
    18801999void Algo_hash::AW_process(int x, int y) { 
    1881   for(vector<pair<long long, ExtendedMoveNumber>* >::iterator it = lfc->begin(); it != lfc->end(); it++) { 
     2000  for(vector<pair<hashtype, ExtendedMoveNumber>* >::iterator it = lfc->begin(); it != lfc->end(); it++) { 
    18822001    Move* continuation = new Move(x,y,'W'); 
    18832002    if (insert_hash((*it)->first, (*it)->second, continuation) != 0) throw DBError(); 
     
    18862005  } 
    18872006  delete lfc; 
    1888   lfc = new vector<pair<long long, ExtendedMoveNumber>* >; 
     2007  lfc = new vector<pair<hashtype, ExtendedMoveNumber>* >; 
    18892008  currentHashCode -= hashCodes[x + boardsize*y]; 
    18902009}                  
     
    18962015 
    18972016void Algo_hash::endOfNode_process() { 
    1898   lfc->push_back(new pair<long long, ExtendedMoveNumber>(currentHashCode, *moveNumber)); 
     2017  lfc->push_back(new pair<hashtype, ExtendedMoveNumber>(currentHashCode, *moveNumber)); 
    18992018  moveNumber->next(); 
    19002019} 
     
    19052024 
    19062025void Algo_hash::move_process(Move m) throw(DBError) { 
    1907   for(vector<pair<long long, ExtendedMoveNumber>* >::iterator it = lfc->begin(); it != lfc->end(); it++) { 
     2026  for(vector<pair<hashtype, ExtendedMoveNumber>* >::iterator it = lfc->begin(); it != lfc->end(); it++) { 
    19082027    Move* continuation = new Move(m); 
    19092028    int rc = insert_hash((*it)->first, (*it)->second, continuation); 
     
    19132032  } 
    19142033  delete lfc; 
    1915   lfc = new vector<pair<long long, ExtendedMoveNumber>* >; 
     2034  lfc = new vector<pair<hashtype, ExtendedMoveNumber>* >; 
    19162035  int epsilon = (m.color == 'B' || m.color == 'X' ? 1 : -1); 
    19172036  currentHashCode += epsilon * hashCodes[m.x + boardsize*m.y]; 
     
    19342053 
    19352054void Algo_hash::endOfVariation_process() { 
    1936   for(vector<pair<long long, ExtendedMoveNumber>* >::iterator it = lfc->begin(); it != lfc->end(); it++) { 
     2055  for(vector<pair<hashtype, ExtendedMoveNumber>* >::iterator it = lfc->begin(); it != lfc->end(); it++) { 
    19372056    int rc = insert_hash((*it)->first, (*it)->second, 0); 
    19382057    if (rc != 0) printf("ouch %d\n", rc); // FIXME 
     
    19492068 
    19502069void Algo_hash::endgame_process() { 
    1951   for(vector<pair<long long, ExtendedMoveNumber>* >::iterator it = lfc->begin(); it != lfc->end(); it++) { 
     2070  for(vector<pair<hashtype, ExtendedMoveNumber>* >::iterator it = lfc->begin(); it != lfc->end(); it++) { 
    19522071    Move* continuation = 0; 
    19532072    int rc = insert_hash((*it)->first, (*it)->second, continuation); 
     
    19642083 
    19652084 
    1966 long long Algo_hash::compute_hashkey(Pattern& pattern) { 
     2085hashtype Algo_hash::compute_hashkey(Pattern& pattern) { 
    19672086  if (pattern.sizeX != boardsize || pattern.sizeY != boardsize) 
    19682087    return NOT_HASHABLE; 
    1969   long long hashkey = 0; 
     2088  hashtype hashkey = 0; 
    19702089             
    19712090  for(int i=0; i<boardsize; i++) { 
     
    20282147    // printf("enter algo_hash.search %d\n", plS); 
    20292148    for(int N=0; N<plS; N++) { 
    2030       long long hashCode = compute_hashkey(patternList.data[N]); 
     2149      hashtype hashCode = compute_hashkey(patternList.data[N]); 
    20312150      if (hashCode == NOT_HASHABLE) return -1; // failure 
    20322151 
     
    27002819    throw DBError(); 
    27012820  } 
     2821  rc = sqlite3_busy_timeout(db, 200); 
     2822  if (rc) throw DBError(); 
    27022823  rc = sqlite3_exec(db, "pragma synchronous = off;", 0, 0, 0); 
    27032824  if (rc) throw DBError(); 
  • 06/libkombilo/search.h

    r188 r191  
    3131#include "abstractboard.h" 
    3232#include "sgfparser.h" 
    33 using namespace std; 
    3433typedef char* char_p; 
     34 
     35#ifdef __BORLANDC__ 
     36typedef __int64 hashtype; 
     37#else 
     38typedef long long hashtype; 
     39#endif 
    3540 
    3641const char NO_CONT = 255; 
     
    5762    Symmetries(const Symmetries& s); 
    5863    Symmetries& operator=(const Symmetries& s); 
    59     void set(char i, char j, char k, char l, char cs)
    60     char getX(char i, char j)
    61     char getY(char i, char j)
    62     char getCS(char i, char j)
    63     char has_key(char i, char j)
     64    void set(char i, char j, char k, char l, char cs) throw(PatternError)
     65    char getX(char i, char j) throw(PatternError)
     66    char getY(char i, char j) throw(PatternError)
     67    char getCS(char i, char j) throw(PatternError)
     68    char has_key(char i, char j) throw(PatternError)
    6469}; 
    6570 
     
    8994    char* initialPos; 
    9095    char* finalPos; 
    91     vector<MoveNC> contList; 
     96    std::vector<MoveNC> contList; 
    9297 
    9398    Pattern(); 
    94     Pattern(int le, int ri, int to, int bo, int sX, int sY, char* iPos, const vector<MoveNC>& CONTLIST); 
    95     Pattern(int type, int boardsize, int sX, int sY, char* iPos, vector<MoveNC> CONTLIST); 
     99    Pattern(int le, int ri, int to, int bo, int sX, int sY, char* iPos, const std::vector<MoveNC>& CONTLIST); 
     100    Pattern(int type, int boardsize, int sX, int sY, char* iPos, std::vector<MoveNC> CONTLIST); 
    96101    Pattern(int type, int boardsize, int sX, int sY, char* iPos); 
    97102    Pattern(const Pattern& p); 
     
    105110    char BW2XO(char c); 
    106111    int operator==(const Pattern& p); 
    107     void printPattern(); 
     112    std::string printPattern(); 
    108113 
    109114    static int flipsX(int i, int x, int y, int XX, int YY); 
     
    131136    int fixedColor;                      // allow switching colors 
    132137    int nextMove;                        // 1: next must be black, 2: next must be white 
    133     vector<Pattern> data; 
    134     vector<Symmetries> symmetries; 
     138    std::vector<Pattern> data; 
     139    std::vector<Symmetries> symmetries; 
    135140    Continuation* continuations; 
    136141    int special; 
     
    138143    PatternList(Pattern& p, int fColor, int nMove, int bsize); 
    139144    ~PatternList(); 
    140     PatternList(const PatternList& pl); 
    141     PatternList& operator=(const PatternList& pl); 
    142145 
    143146    char invertColor(char co); 
     
    210213    void branchpoint_process(); 
    211214    void endOfVariation_process(); 
    212     void endgame_process()
     215    void endgame_process() throw(DBError)
    213216    void finalize_process(); 
    214217 
    215218    int counter; 
    216219    char* signature; 
    217     vector<char* > *datasig; 
     220    std::vector<char* > *datasig; 
    218221  private: 
    219222    bool main_variation; 
     
    234237    void branchpoint_process(); 
    235238    void endOfVariation_process(); 
    236     void endgame_process()
     239    void endgame_process() throw(DBError)
    237240    void finalize_process(); 
    238241 
    239242    char* fp; 
    240243    int fpIndex; 
    241     vector<char* > *data; 
     244    std::vector<char* > *data; 
    242245    int readDB(sqlite3* DB); 
    243246    int search(PatternList& patternList, GameList& gl, SearchOptions& options); 
     
    266269    bool dictsDR; 
    267270    int dictsNO; 
    268     vector<MoveNC> contList; 
     271    std::vector<MoveNC> contList; 
    269272    int contListIndex; 
    270     pair<char,char> Xinterv; 
    271     pair<char,char> Yinterv; 
     273    p_cc Xinterv; 
     274    p_cc Yinterv; 
    272275    char mx; 
    273276    char my; 
     
    280283}; 
    281284 
    282 class VecMC : public vector<MovelistCand* > { 
     285class VecMC : public std::vector<MovelistCand* > { 
    283286  public: 
    284287    VecMC(); 
     
    303306    void branchpoint_process(); 
    304307    void endOfVariation_process(); 
    305     void endgame_process()
     308    void endgame_process() throw(DBError)
    306309    void finalize_process(); 
    307310    int readDB(sqlite3* DB); 
    308311    int search(PatternList& patternList, GameList& gl, SearchOptions& options); 
    309312 
    310     vector<char> movelist; 
     313    std::vector<char> movelist; 
    311314    char* fpC; 
    312     vector<char* > *data1; 
    313     vector<char* > *data2; 
    314     vector<int> *data1l; 
    315 }; 
    316  
    317 const long long NOT_HASHABLE = 9223372036854775807LL; 
     315    std::vector<char* > *data1; 
     316    std::vector<char* > *data2; 
     317    std::vector<int> *data1l; 
     318}; 
     319 
     320const hashtype NOT_HASHABLE = 9223372036854775807LL; 
    318321 
    319322 
     
    332335class HashVarInfo { 
    333336  public: 
    334     long long chc; 
    335     vector<pair<long long, ExtendedMoveNumber>* > * lfc; 
     337    hashtype chc; 
     338    std::vector<std::pair<hashtype, ExtendedMoveNumber>* > * lfc; 
    336339    ExtendedMoveNumber* moveNumber; 
    337340 
    338     HashVarInfo(long long CHC, vector<pair<long long, ExtendedMoveNumber>* > * LFC, ExtendedMoveNumber* MOVENUMBER); 
     341    HashVarInfo(hashtype CHC, std::vector<std::pair<hashtype, ExtendedMoveNumber>* > * LFC, ExtendedMoveNumber* MOVENUMBER); 
    339342}; 
    340343 
     
    357360    int search(PatternList& patternList, GameList& gl, SearchOptions& options, sqlite3* db); 
    358361 
    359     int insert_hash(long long hashCode, ExtendedMoveNumber& mn, Move* continuation); 
    360     long long compute_hashkey(Pattern& pattern); 
    361  
    362     long long currentHashCode; 
     362    int insert_hash(hashtype hashCode, ExtendedMoveNumber& mn, Move* continuation); 
     363    hashtype compute_hashkey(Pattern& pattern); 
     364 
     365    hashtype currentHashCode; 
    363366    ExtendedMoveNumber* moveNumber; 
    364     vector<pair<long long, ExtendedMoveNumber>* > *lfc; // hash code + move number, still looking for continuation 
    365     stack<HashVarInfo>* branchpoints; 
    366  
    367     static const long long hashCodes[]; 
     367    std::vector<std::pair<hashtype, ExtendedMoveNumber>* > *lfc; // hash code + move number, still looking for continuation 
     368    std::stack<HashVarInfo>* branchpoints; 
     369 
     370    static const hashtype hashCodes[]; 
    368371}; 
    369372 
     
    378381//   int isEmpty(); 
    379382//  
    380 //   vector<pair<int,int>> data; 
     383//   std::vector<pair<int,int>> data; 
    381384//  
    382385// }; 
     
    388391//   ~Algo_intervals(); 
    389392//  
    390 //   vector<long> movesArr; 
    391 //   vector<long> moveIntsArr; 
    392 //  
    393 //   vector<vector<int>*> moves; 
     393//   std::vector<long> movesArr; 
     394//   std::vector<long> moveIntsArr; 
     395//  
     396//   std::vector<vector<int>*> moves; 
    394397//  
    395398//   int counter; 
     
    435438  public: 
    436439    int id; // id within the concerning database 
    437     string gameInfoStr; 
     440    std::string gameInfoStr; 
    438441    char winner; 
    439     vector<Hit* > * hits; // used for hits 
    440     vector<Candidate* > * candidates; // used for candidates 
    441  
    442     GameListEntry(int ID, char WINNER, string GAMEINFOSTR); 
     442    std::vector<Hit* > * hits; // used for hits 
     443    std::vector<Candidate* > * candidates; // used for candidates 
     444 
     445    GameListEntry(int ID, char WINNER, std::string GAMEINFOSTR); 
    443446    ~GameListEntry(); 
    444447}; 
     
    458461  public: 
    459462    char* dbname; 
    460     string orderby; 
     463    std::string orderby; 
    461464                    // constructor receives a FORMAT string; see trac wiki for the syntax to be used 
    462     string format1; // extracted from FORMAT; the column list of the sql query to retrieve the games  
    463     string format2; // extracted from FORMAT, used as template when inserting the query results into the game list 
     465    std::string format1; // extracted from FORMAT; the column list of the sql query to retrieve the games  
     466    std::string format2; // extracted from FORMAT, used as template when inserting the query results into the game list 
    464467    int numColumns; 
    465468    int algos; 
     
    467470    int processVariations; 
    468471    algo_p* algo_ps; 
    469     vector<GameListEntry* > * all; 
    470     vector<pair<int,int> > * currentList; // pair of game id and position within all 
     472    std::vector<GameListEntry* > * all; 
     473    std::vector<std::pair<int,int> > * currentList; // pair of game id and position within all 
    471474                                          // (usually sorted w.r.t. second 
    472475                                          // component) 
    473     vector<pair<int,int> > * oldList; 
     476    std::vector<std::pair<int,int> > * oldList; 
    474477    int current; 
    475478    sqlite3* db; 
     
    479482 
    480483    // the following methods provide the user interface 
    481     GameList(char* DBNAME, string ORDERBY, string FORMAT, int ALGOS, int BOARDSIZE) throw(DBError); 
     484    GameList(char* DBNAME, std::string ORDERBY, std::string FORMAT, int ALGOS, int BOARDSIZE) throw(DBError); 
    482485 
    483486    void search(Pattern& pattern, SearchOptions& options) throw(DBError); 
     
    486489    void gisearch(char* sql) throw(DBError); 
    487490    int size(); 
    488     vector<string> currentEntriesAsStrings(int start=0, int end=0); 
     491    std::vector<std::string> currentEntriesAsStrings(int start=0, int end=0); 
    489492    int numHits(); 
    490493 
     
    500503    int end_sorted(); 
    501504    char getCurrentWinner(); 
    502     vector<Candidate* > *getCurrentCandidateList(); 
    503     void makeCurrentCandidate(vector<Candidate* > *candidates); 
    504     void makeCurrentHit(vector<Hit* > *hits); 
    505     void makeIndexCandidate(int index, vector<Candidate* > *candidates); 
    506     void makeIndexHit(int index, vector<Hit* > *hits); 
     505    std::vector<Candidate* > *getCurrentCandidateList(); 
     506    void makeCurrentCandidate(std::vector<Candidate* > *candidates); 
     507    void makeCurrentHit(std::vector<Hit* > *hits); 
     508    void makeIndexCandidate(int index, std::vector<Candidate* > *candidates); 
     509    void makeIndexHit(int index, std::vector<Hit* > *hits); 
    507510 
    508511  private: 
    509     string resultsStr(GameListEntry* gle); 
     512    std::string resultsStr(GameListEntry* gle); 
    510513    char lookupLabel(char x, char y); 
    511514    void readDB(); 
  • 06/libkombilo/sgfparser.cc

    r190 r191  
    2323 
    2424#include "sgfparser.h" 
     25 
     26using std::vector; 
     27using std::stack; 
     28using std::pair; 
     29using std::map; 
     30using std::string; 
    2531 
    2632SGFError::SGFError() {} 
     
    400406        else i++; 
    401407      } 
    402       data.insert(make_pair(ID, propValueList)); 
     408      data.insert(make_pair(string(ID), propValueList)); 
    403409    } 
    404410    parsed = 1; 
  • 06/libkombilo/sgfparser.h

    r188 r191  
    3030#include <stack> 
    3131#include <map> 
    32 using namespace std; 
    3332 
    34 typedef pair<char,char> p_cc; 
     33typedef std::pair<char,char> p_cc; 
    3534 
    3635class SGFError { 
     
    6867    int numChildren; 
    6968    int level; 
    70     string SGFstring; 
     69    std::string SGFstring; 
    7170    int parsed; 
    72     vector<string> gpv(const string& prop); 
    73     vector<string>* get_property_value(const string& prop); 
    74     void set_property_value(string& ID, vector<string>* propValue) throw(SGFError); 
     71    std::vector<std::string> gpv(const std::string& prop); 
     72    std::vector<std::string>* get_property_value(const std::string& prop); 
     73    void set_property_value(std::string& ID, std::vector<std::string>* propValue) throw(SGFError); 
    7574 
    7675    int posyD; // used when displaying SGF structure graphically as a tree 
     
    8281    static int sloppy; 
    8382  private: 
    84     map<string, vector<string>* > data; // use get_property_value to access this 
     83    std::map<std::string, std::vector<std::string>* > data; // use get_property_value to access this 
    8584}; 
    8685 
     
    139138}; 
    140139 
    141 string nodeToString(map<string, vector<string>* >& data) throw(SGFError); 
     140std::string nodeToString(std::map<std::string, std::vector<std::string>* >& data) throw(SGFError); 
    142141// char* rootNodeToString(PyObject* data); 
    143142