Show
Ignore:
Timestamp:
03/09/07 16:38:11 (2 years ago)
Author:
ug
Message:

Handling of duplicates within GameList, also during process.
Better access to processing results.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • 06/libkombilo/cpptest.cpp

    r230 r239  
    2929    gl.start_processing(); 
    3030    directory_iterator end_itr; 
    31     string path = "/home/ug/go/kombilo/06/libkombilo"; 
     31    // string path = "/home/ug/go/kombilo/06/libkombilo"; 
    3232    // string path = "/home/ug/go/gtl/reviews"; 
    33     // string path = "/home/ug/go/gogod06/2000"; 
     33    string path = "/home/ug/go/gogod06/1998"; 
     34    int counter = 0; 
    3435    for(directory_iterator it(path); it != end_itr; ++it) { 
    3536      string n = it->string(); 
     
    4647        } 
    4748        infile.close(); 
    48         gl.process(sgf.c_str(), path.c_str(), n.c_str());    
     49        int flags = CHECK_FOR_DUPLICATES; // |OMIT_DUPLICATES; 
     50        if (gl.process(sgf.c_str(), path.c_str(), n.c_str(), "", flags)) 
     51          if (gl.process_results() & IS_DUPLICATE) printf("is duplicate: %d\n", counter); 
     52        counter++; 
    4953      } 
    5054    } 
    5155    gl.finalize_processing(); 
    52     printf("Processed %d games.\n", gl.size()); 
     56    printf("Now %d games in db.\n", gl.size()); 
    5357  } 
    5458  printf("%d games.\n", gl.size()); 
     
    9094   
    9195  // -------------------- do pattern search -------------------------------------- 
    92   gl.search(p, &so); 
     96  // gl.search(p, &so); 
    9397 
    9498  // ------------------- print some information about current list of games ------------ 
    95   printf("num games: %d, num hits: %d\n", gl.size(), gl.numHits()); 
     99  // printf("num games: %d, num hits: %d\n", gl.size(), gl.numHits()); 
    96100  // vector<string> res = gl.currentEntriesAsStrings(); 
    97101  // for(vector<string>::iterator it = res.begin(); it != res.end(); it++) 
     
    100104 
    101105  // ------------------- print some statistics ------------------------------------------ 
    102   printf("Search pattern:\n"); 
    103   printf("%s\n", p.printPattern().c_str()); 
    104   printf("Continuations:\n"); 
    105   for(int y=0; y<p.sizeY; y++) { 
    106     for(int x=0; x<p.sizeX; x++) { 
    107       printf("%c", gl.lookupLabel(x,y)); 
     106  // printf("Search pattern:\n"); 
     107  // printf("%s\n", p.printPattern().c_str()); 
     108  // printf("Continuations:\n"); 
     109  // for(int y=0; y<p.sizeY; y++) { 
     110  //   for(int x=0; x<p.sizeX; x++) { 
     111  //     printf("%c", gl.lookupLabel(x,y)); 
     112  //   } 
     113  //   printf("\n"); 
     114  // } 
     115  // printf("\n"); 
     116  // printf("Statistics:\n");  
     117  // printf("num hits: %d, num switched: %d, B wins: %d, W wins: %d\n", gl.num_hits, gl.num_switched, gl.Bwins, gl.Wwins); 
     118 
     119  // printf("Continuation | Black      ( B wins / W wins ) | White      (B wins / W wins) |\n"); 
     120  // for(int y=0; y<p.sizeY; y++) { 
     121  //   for(int x=0; x<p.sizeX; x++) { 
     122  //     if (gl.lookupLabel(x,y) != '.') { 
     123  //       Continuation cont = gl.lookupContinuation(x,y); 
     124  //       printf("      %c      |   %3d[%3d] (    %3d /    %3d ) |   %3d[%3d] (   %3d /    %3d) | %1.1f /  %1.1f \n", 
     125  //           gl.lookupLabel(x,y), cont.B, cont.tB, cont.wB, cont.lB, cont.W, cont.tW, cont.wW, cont.lW,  
     126  //           cont.wW*100.0/cont.W, cont.wB*100.0/cont.B); 
     127  //     } 
     128  //   } 
     129  // } 
     130 
     131  // ------------------- check for duplicates --------------------------------- 
     132  gl.reset(); 
     133  int nd = gl.find_duplicates(19); 
     134  printf("duplicates:\n"); 
     135  for(int i=0; i<nd; i++) { 
     136    // 1st method: retrieve_duplicates_VI 
     137    // vector<int> dupl_vector = gl.retrieve_duplicates_VI(i); 
     138    // for(vector<int>::iterator it = dupl_vector.begin(); it != dupl_vector.end(); it++) { 
     139    //   printf("%s%s\n", gl.currentEntryAsString(*it).c_str(), gl.getSignature(*it).c_str()); 
     140    // } 
     141     
     142    // 2nd method: retrieve_duplicates_PI 
     143    int * dupl_vector = gl.retrieve_duplicates_PI(i); 
     144    int j = 0; 
     145    while(dupl_vector[j] != -1) { 
     146      printf("%s%s\n", gl.currentEntryAsString(dupl_vector[j]).c_str(), gl.getSignature(dupl_vector[j]).c_str()); 
     147      j++; 
    108148    } 
    109     printf("\n"); 
    110   } 
    111   printf("\n"); 
    112   printf("Statistics:\n");  
    113   printf("num hits: %d, num switched: %d, B wins: %d, W wins: %d\n", gl.num_hits, gl.num_switched, gl.Bwins, gl.Wwins); 
     149    delete [] dupl_vector; 
    114150 
    115   printf("Continuation | Black      ( B wins / W wins ) | White      (B wins / W wins) |\n"); 
    116   for(int y=0; y<p.sizeY; y++) { 
    117     for(int x=0; x<p.sizeX; x++) { 
    118       if (gl.lookupLabel(x,y) != '.') { 
    119         Continuation cont = gl.lookupContinuation(x,y); 
    120         printf("      %c      |   %3d[%3d] (    %3d /    %3d ) |   %3d[%3d] (   %3d /    %3d) | %1.1f /  %1.1f \n", 
    121             gl.lookupLabel(x,y), cont.B, cont.tB, cont.wB, cont.lB, cont.W, cont.tW, cont.wW, cont.lW,  
    122             cont.wW*100.0/cont.W, cont.wB*100.0/cont.B); 
    123       } 
    124     } 
     151    printf("--------------------------------------------------- \n"); 
    125152  } 
    126153