Changeset 238 for 06/libkombilo-branches/hash_center/search.h
- Timestamp:
- 03/06/07 23:08:07 (22 months ago)
- Files:
-
- 1 modified
-
06/libkombilo-branches/hash_center/search.h (modified) (11 diffs)
Legend:
- Unmodified
- Added
- Removed
-
06/libkombilo-branches/hash_center/search.h
r233 r238 82 82 const int FULLBOARD_PATTERN = 9; 83 83 84 class PatternList; 85 84 86 class Pattern { 85 87 public: … … 99 101 char* contLabels; 100 102 std::vector<MoveNC> contList; 103 101 104 102 105 // Pattern constructors … … 117 120 Pattern& copy(const Pattern& p); 118 121 122 Pattern& apply_flip(int f, bool CS = true); 123 Pattern& subpattern(int offsetX, int offsetY, int sizeX, int sizeY); 119 124 char getInitial(int i, int j); 120 125 char getFinal(int i, int j); … … 128 133 static int PatternInvFlip(int i); 129 134 static int compose_flips(int i, int j); // returns index of flip "first j, then i" 135 // static int compose_flips_CS(int i, int j); // similarly, but taking CS into account (i.e. 0<=i,j<16) 130 136 }; 131 137 … … 151 157 std::vector<Symmetries> symmetries; 152 158 Continuation* continuations; 159 // flipTable encodes the action of the group of symmetries of the square times Z/2 (for color switch) 160 // on pattern: flipTable[i] is the index in data of the pattern resulting from applying flip i and no 161 // CS (0<=i<8), or flip i-8 and CS (8<=i<16) to pattern. 153 162 int* flipTable; 163 // special is -1, or equal to the inverse of the flip which maps pattern to its CS'ed pattern 154 164 int special; 155 165 … … 157 167 ~PatternList(); 158 168 159 char invertColor(char co);169 // static char invertColor(char co); 160 170 void patternList(); 161 171 Pattern get(int i); … … 342 352 }; 343 353 344 class HashhitCS { // has ihing hit for corner/sidepattern search354 class HashhitCS { // hashing hit for corner/side/center pattern search 345 355 public: 346 356 int gameid; … … 443 453 }; 444 454 455 class CompleteHashKey { 456 // returned by compute_hashkey 457 // contains the information about which subpattern was used to compute the actual hashCode 458 public: 459 hashtype hashCode; 460 int offsetX; 461 int offsetY; 462 int index; // index in corresp. patternList 463 464 CompleteHashKey(); // = NOT_HASHABLE 465 CompleteHashKey(hashtype HASHCODE, int OFFSETX, int OFFSETY, int INDEX); 466 }; 467 468 class HashQuery { 469 public: 470 std::string sql; 471 PatternList* pl0; 472 PatternList* pl1; 473 int flip0; 474 int flip1; 475 int offset0; 476 int offset1; 477 hashtype hashCode0; 478 479 HashQuery(std::string SQL, Pattern* p0, int OFF0, int FLIP0, hashtype HASHCODE0, Pattern* p1, int OFF1, int FLIP1); 480 ~HashQuery(); 481 }; 445 482 446 483 class Algo_hash : public Algorithm { … … 463 500 virtual void endgame_process(); 464 501 virtual void finalize_process(); 502 virtual HashQuery searchQuery(PatternList& patternList); 465 503 virtual int search(PatternList& patternList, GameList& gl, SearchOptions& options, sqlite3* db); 466 504 467 505 virtual int insert_hash(hashtype hashCod, int pos); 468 virtual std::pair<hashtype,int>compute_hashkey(PatternList& pl, int CS);506 virtual CompleteHashKey compute_hashkey(PatternList& pl, int CS); 469 507 std::vector<HashInstance* >* hi; 470 508 std::string dbnameext; … … 477 515 public: 478 516 Algo_hash_corner(int bsize, int SIZE=7, int MAXNUMSTONES = 20); 479 std::pair<hashtype,int> compute_hashkey(PatternList& pl, int CS); 517 CompleteHashKey compute_hashkey(PatternList& pl, int CS); 518 void initialize_process(sqlite3* DB) throw(DBError); 519 HashQuery searchQuery(PatternList& patternList); 480 520 int size; 481 521 }; … … 492 532 Algo_hash_center(int bsize); 493 533 void initialize_process(sqlite3* DB) throw(DBError); 534 void finalize_process(); 494 535 void endOfNode_process(); 495 void finalize_process();496 std::pair<hashtype,int> compute_hashkey(PatternList& pl, int CS);536 CompleteHashKey compute_hashkey(PatternList& pl, int CS); 537 HashQuery searchQuery(PatternList& patternList); 497 538 498 539 std::map<hashtype, int> data; 540 private: 541 std::map<hashtype, int> frequency; 499 542 }; 500 543
