Show
Ignore:
Timestamp:
03/06/07 23:08:07 (22 months ago)
Author:
ug
Message:

Backup of current state (does compile, but hashing is not functional ATM).

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • 06/libkombilo-branches/hash_center/search.h

    r233 r238  
    8282const int FULLBOARD_PATTERN = 9; 
    8383 
     84class PatternList; 
     85 
    8486class Pattern { 
    8587  public: 
     
    99101    char* contLabels; 
    100102    std::vector<MoveNC> contList; 
     103 
    101104 
    102105    // Pattern constructors 
     
    117120    Pattern& copy(const Pattern& p); 
    118121 
     122    Pattern& apply_flip(int f, bool CS = true); 
     123    Pattern& subpattern(int offsetX, int offsetY, int sizeX, int sizeY); 
    119124    char getInitial(int i, int j); 
    120125    char getFinal(int i, int j); 
     
    128133    static int PatternInvFlip(int i); 
    129134    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) 
    130136}; 
    131137 
     
    151157    std::vector<Symmetries> symmetries; 
    152158    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. 
    153162    int* flipTable; 
     163    // special is -1, or equal to the inverse of the flip which maps pattern to its CS'ed pattern 
    154164    int special; 
    155165 
     
    157167    ~PatternList(); 
    158168 
    159     char invertColor(char co); 
     169    // static char invertColor(char co); 
    160170    void patternList(); 
    161171    Pattern get(int i); 
     
    342352}; 
    343353 
    344 class HashhitCS { // hasihing hit for corner/side pattern search 
     354class HashhitCS { // hashing hit for corner/side/center pattern search 
    345355  public: 
    346356    int gameid; 
     
    443453}; 
    444454 
     455class 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 
     468class 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}; 
    445482 
    446483class Algo_hash : public Algorithm { 
     
    463500    virtual void endgame_process(); 
    464501    virtual void finalize_process(); 
     502    virtual HashQuery searchQuery(PatternList& patternList); 
    465503    virtual int search(PatternList& patternList, GameList& gl, SearchOptions& options, sqlite3* db); 
    466504 
    467505    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); 
    469507    std::vector<HashInstance* >* hi; 
    470508    std::string dbnameext; 
     
    477515  public: 
    478516    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); 
    480520    int size; 
    481521}; 
     
    492532    Algo_hash_center(int bsize); 
    493533    void initialize_process(sqlite3* DB) throw(DBError); 
     534    void finalize_process(); 
    494535    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); 
    497538 
    498539    std::map<hashtype, int> data; 
     540  private: 
     541    std::map<hashtype, int> frequency; 
    499542}; 
    500543