Changeset 230
- Timestamp:
- 03/02/07 00:27:09 (1 year ago)
- Files:
-
- 06/libkombilo/cpptest.cpp (modified) (4 diffs)
- 06/libkombilo/search.cpp (modified) (8 diffs)
- 06/libkombilo/search.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
06/libkombilo/cpptest.cpp
r229 r230 67 67 // Pattern p(2,3,4,6, 19, 3, 3, ".X.XXXXOX", vector<MoveNC>()); 68 68 69 Pattern p(CORNER_NW_PATTERN,19,8,8,"...................X......X.......XO......OO....................");69 // Pattern p(CORNER_NW_PATTERN,19,8,8,"...................X......X.......XO......OO...................."); 70 70 // Pattern p(CORNER_NW_PATTERN,19,7,7,".................X.....X......XO.....OO.........."); 71 71 // Pattern p(CORNER_NW_PATTERN,19,7,7,".......................X........................."); 72 72 73 73 // gl.gisearch("pw = 'Hane Naoki'"); 74 //Pattern p(CENTER_PATTERN, 19, 3, 5, ".X..OX.OX.OXOXO");74 Pattern p(CENTER_PATTERN, 19, 3, 5, ".X..OX.OX.OXOXO"); 75 75 // vector<MoveNC> contList; 76 76 // contList.push_back(MoveNC(6,15,'X')); … … 80 80 // 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............."); 81 81 82 // Pattern p(FULLBOARD_PATTERN,19,19,19,"........................................................................O......................................................................................................................................................................................................................X........................................................................."); 83 82 84 // -------------------- set up search options ---------------------------------- 83 85 SearchOptions so; 86 // so.trustHashFull = true; 84 87 // SearchOptions so(0,0,50); // use move limit 85 88 // so.searchInVariations = false; … … 90 93 91 94 // ------------------- print some information about current list of games ------------ 92 printf("num games: %d, num hits: %d =%d\n", gl.size(), gl.numHits(), gl.num_hits);95 printf("num games: %d, num hits: %d\n", gl.size(), gl.numHits()); 93 96 // vector<string> res = gl.currentEntriesAsStrings(); 94 97 // for(vector<string>::iterator it = res.begin(); it != res.end(); it++) … … 110 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); 111 114 112 printf("Continuation | Black ( B wins / W wins ) | White(B wins / W wins) |\n");115 printf("Continuation | Black ( B wins / W wins ) | White (B wins / W wins) |\n"); 113 116 for(int y=0; y<p.sizeY; y++) { 114 117 for(int x=0; x<p.sizeX; x++) { 115 118 if (gl.lookupLabel(x,y) != '.') { 116 119 Continuation cont = gl.lookupContinuation(x,y); 117 printf(" %c | %3d ( %3d / %3d ) | %3d( %3d / %3d) | %1.1f / %1.1f \n",118 gl.lookupLabel(x,y), cont.B, cont. wB, cont.lB, cont.W, cont.wW, cont.lW,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, 119 122 cont.wW*100.0/cont.W, cont.wB*100.0/cont.B); 120 123 } 06/libkombilo/search.cpp
r229 r230 722 722 yy = symmetries[index].getY(x,y); 723 723 cSymm = symmetries[index].getCS(x,y); 724 if (co == 'X' ) {724 if (co == 'X' || co == 'B') { 725 725 if (cSymm) cc = 'W'; else cc = 'B'; 726 726 } else { … … 2313 2313 2314 2314 int Algo_hash_full::search(PatternList& patternList, GameList& gl, SearchOptions& options, sqlite3* db) { 2315 // printf("enter algo_hash_full::search\n"); 2316 int numOfHits = 0; 2317 int self_numOfSwitched = 0; 2318 int Bwins = 0; 2319 int Wwins = 0; 2320 2315 2321 int hash_result = -1; // -1 = failure; 0 = ok, but have to check w/ Algo_movelist, 1 = ok, produced final result 2316 2322 int plS = patternList.size(); … … 2336 2342 2337 2343 if (hash_result) { 2344 gl.setCurrentFromIndex(index); 2345 int numOfSwitched = 0; 2338 2346 vector<Hit* >* hits = new vector<Hit* >; 2339 2347 while ((*resultIT)->gameid == index) { … … 2346 2354 label = patternList.updateContinuations((*resultIT)->orientation, 2347 2355 (*resultIT)->cont->x, (*resultIT)->cont->y, (*resultIT)->cont->color, 2348 false, gl.getCurrentWinner()); 2356 false, // tenuki impossible with full board pattern 2357 gl.getCurrentWinner()); 2349 2358 if (label) { 2350 2359 hits->push_back(new Hit((*resultIT)->emn, label)); 2351 2360 (*resultIT)->emn = 0; 2361 numOfSwitched += label[2]; 2352 2362 } 2353 2363 } else { … … 2356 2366 label[1] = 0; 2357 2367 label[2] = patternList.data[(*resultIT)->orientation].colorSwitch; 2368 numOfSwitched += label[2]; 2358 2369 hits->push_back(new Hit((*resultIT)->emn, label)); 2359 2370 (*resultIT)->emn = 0; … … 2362 2373 if (resultIT == results->end()) break; 2363 2374 } 2364 if (hits->size()) gl.makeIndexHit(index, hits); 2365 else delete hits; 2375 if (hits->size()) { 2376 numOfHits += hits->size(); 2377 self_numOfSwitched += numOfSwitched; 2378 if (gl.getCurrentWinner() == 'B') { 2379 Bwins += hits->size() - numOfSwitched; 2380 Wwins += numOfSwitched; 2381 } else if (gl.getCurrentWinner() == 'W') { 2382 Bwins += numOfSwitched; 2383 Wwins += hits->size() - numOfSwitched; 2384 } 2385 gl.makeCurrentHit(hits); 2386 } else delete hits; 2366 2387 } else { // produce Candidate list, check using another algorithm 2367 2388 vector<Candidate* >* candidates = new vector<Candidate* >; … … 2379 2400 gl.end_sorted(); 2380 2401 } 2381 return 0; 2402 gl.num_hits = numOfHits; 2403 gl.num_switched = self_numOfSwitched; 2404 gl.Bwins = Bwins; 2405 gl.Wwins = Wwins; 2406 return hash_result; 2382 2407 } 2383 2408 … … 3736 3761 sort(gle->hits->begin(), gle->hits->end(), Hit::cmp_pts); 3737 3762 currentList->push_back((*oldList)[current]); 3763 } 3764 3765 void GameList::setCurrentFromIndex(int index) { 3766 int start = current; 3767 int end = oldList->size(); 3768 int m = start; 3769 while (start < end) { 3770 m = (end+start)/2; 3771 if (index == (*oldList)[m].first) { 3772 break; 3773 } else { 3774 if (index < (*oldList)[m].first) end = m; 3775 else start = m+1; 3776 } 3777 } 3778 current = m; 3738 3779 } 3739 3780 06/libkombilo/search.h
r229 r230 658 658 void makeIndexCandidate(int index, std::vector<Candidate* > *candidates); 659 659 void makeIndexHit(int index, std::vector<Hit* > *hits); 660 void setCurrentFromIndex(int index); 660 661 661 662 private:
