Changeset 239 for 06/libkombilo/search.h
- Timestamp:
- 03/09/07 16:38:11 (22 months ago)
- Files:
-
- 1 modified
-
06/libkombilo/search.h (modified) (13 diffs)
Legend:
- Unmodified
- Added
- Removed
-
06/libkombilo/search.h
r230 r239 201 201 virtual void branchpoint_process(); 202 202 virtual void endOfVariation_process(); 203 virtual void endgame_process( );203 virtual void endgame_process(bool commit=true); 204 204 virtual void finalize_process(); 205 205 virtual int readDB(sqlite3* DB); … … 225 225 void branchpoint_process(); 226 226 void endOfVariation_process(); 227 void endgame_process( ) throw(DBError);227 void endgame_process(bool commit=true) throw(DBError); 228 228 void finalize_process(); 229 229 230 230 int counter; 231 231 char* signature; 232 char* get_current_signature(); 233 std::vector<int> search_signature(char* sig); 232 234 private: 233 235 bool main_variation; … … 248 250 void branchpoint_process(); 249 251 void endOfVariation_process(); 250 void endgame_process( ) throw(DBError);252 void endgame_process(bool commit=true) throw(DBError); 251 253 void finalize_process(); 252 254 … … 256 258 int readDB(sqlite3* DB); 257 259 int search(PatternList& patternList, GameList& gl, SearchOptions& options); 260 261 bool equal(unsigned int id1, unsigned int id2); // id1, id2 refer to id's in the database! 262 bool equals_current(unsigned int id1); 258 263 }; 259 264 … … 317 322 void branchpoint_process(); 318 323 void endOfVariation_process(); 319 void endgame_process( ) throw(DBError);324 void endgame_process(bool commit=true) throw(DBError); 320 325 void finalize_process(); 321 326 int readDB(sqlite3* DB); … … 329 334 }; 330 335 336 class HashFEntry { 337 public: 338 hashtype hashCode; 339 char* buf; 340 int length; 341 342 HashFEntry(hashtype HASHCODE, char* BUF, int LENGTH); 343 HashFEntry(const HashFEntry& hfe); 344 ~HashFEntry(); 345 }; 331 346 332 347 class HashhitF { // hashing hit for full board search … … 374 389 void branchpoint_process(); 375 390 void endOfVariation_process() throw(DBError); 376 void endgame_process( ) throw(DBError);391 void endgame_process(bool commit=true) throw(DBError); 377 392 void finalize_process(); 378 393 int search(PatternList& patternList, GameList& gl, SearchOptions& options, sqlite3* db); 379 394 380 int insert_hash(hashtype hashCode, ExtendedMoveNumber& mn, Move* continuation);381 395 hashtype compute_hashkey(Pattern& pattern); 382 396 397 int maxNumStones; 398 int numStones; 399 private: 383 400 hashtype currentHashCode; 384 401 ExtendedMoveNumber* moveNumber; 385 402 std::vector<std::pair<hashtype, ExtendedMoveNumber>* > *lfc; // hash code + move number, still looking for continuation 386 403 std::stack<HashVarInfo>* branchpoints; 387 int maxNumStones; 388 int numStones; 404 int insert_hash(hashtype hashCode, ExtendedMoveNumber& mn, Move* continuation); 405 int insert_all_hashes(); 406 std::vector<HashFEntry> hash_vector; 389 407 }; 390 408 … … 439 457 virtual void branchpoint_process(); 440 458 virtual void endOfVariation_process(); 441 virtual void endgame_process( );459 virtual void endgame_process(bool commit=true); 442 460 virtual void finalize_process(); 443 461 virtual int search(PatternList& patternList, GameList& gl, SearchOptions& options, sqlite3* db); 444 462 463 virtual std::pair<hashtype,int> compute_hashkey(PatternList& pl, int CS); 464 static const hashtype hashCodes[]; 465 std::string dbnameext; 466 std::vector<HashInstance>* hi; 467 int maxNumStones; 468 std::vector<std::pair<hashtype, int> > hash_vector; 445 469 virtual int insert_hash(hashtype hashCod, int pos); 446 virtual std::pair<hashtype,int> compute_hashkey(PatternList& pl, int CS); 447 std::vector<HashInstance>* hi; 448 std::string dbnameext; 449 int maxNumStones; 450 451 static const hashtype hashCodes[]; 470 int insert_all_hashes(); 452 471 }; 453 472 … … 569 588 ~VarInfo(); 570 589 }; 590 591 // process flags (used to determine the behavior for individual games - in contrast to 592 // options which apply to the whole GameList and are given in ProcessOptions) 593 const int CHECK_FOR_DUPLICATES = 1; // check for duplicates using the signature 594 const int CHECK_FOR_DUPLICATES_STRICT = 2; // check for duplicates using the final position 595 // (if ALGO_FINAPOS is available) 596 const int OMIT_DUPLICATES = 4; 597 const int OMIT_GAMES_WITH_SGF_ERRORS = 8; 598 const int INDEX_OUT_OF_RANGE = 16; 599 600 // process return values 601 // 0: SGF error occurred when parsing the "tree structure" (i.e. before parsing the individual nodes) 602 // database was not changed 603 // n>0: n games were processed, use process_results to access the individual results 604 605 // flags used in process_results 606 const int UNACCEPTABLE_BOARDSIZE = 1; // (database not changed) 607 const int SGF_ERROR = 2; 608 // SGF error occurred when playing through the game 609 // (and the rest of the concerning variation was not used). 610 // Depending on OMIT_GAMES_WITH_SGF_ERRORS, everything before this node (and other variations, 611 // if any) was inserted, or the database was not changed. 612 const int IS_DUPLICATE = 4; 613 const int NOT_INSERTED_INTO_DB = 8; 614 571 615 572 616 class GameList { … … 606 650 // ------- processing SGF games (to populate the db) -------------------------- 607 651 void start_processing(int PROCESSVARIATIONS=-1) throw(DBError); 608 int process(const char* sgf, const char* path, const char* fn, const char* DBTREE = 0) throw(SGFError,DBError); 652 int process(const char* sgf, const char* path, const char* fn, 653 const char* DBTREE = 0, int flags=0) throw(SGFError,DBError); 654 int process_results(unsigned int i=0); // result for i-th processed game in most recently processed SGF collection 609 655 void finalize_processing() throw(DBError); 610 656 657 // int remove_game(int index); // TODO 658 // int remove_all_current_games(); 659 611 660 // ------- pattern search ----------------------------------------------------- 612 661 // options is copied in the search method (if != 0), so the caller has to free the pointer … … 629 678 void deleteTag(int tag, int i = -1) throw(DBError); 630 679 std::vector<int> getTags(int i, int tag=0) throw(DBError); // note the order of arguments! 680 681 // ------- duplicates --------------------------------------------------------- 682 int find_duplicates(int bs, bool strict=false) throw(DBError); // return number of duplicate array 683 std::vector<int> retrieve_duplicates_VI(unsigned int i); 684 int* retrieve_duplicates_PI(unsigned int i); // same as above, but returns Pointer to Int 685 // (an array terminated by -1) 686 // The caller must free the pointer himself 687 // (before calling find_duplicates again). 631 688 632 689 // ------- misc --------------------------------------------------------------- … … 659 716 void makeIndexHit(int index, std::vector<Hit* > *hits); 660 717 void setCurrentFromIndex(int index); 718 int get_current_index(int id, int* start); // returns the index in oldList of the game with game id "id" 719 // (if available, otherwise returns -1), 720 // use this between start_sorted and end_sorted 721 int get_current_index_CL(int id, int start=0); // returns the index in currentList of the game with game id "id" 722 // (if available, otherwise returns -1), requires currentList to 723 // be sorted wrt first component (see duplicates()) 661 724 662 725 private: … … 678 741 std::vector<std::string> pl; // list of all players 679 742 void readPlayersList() throw(DBError); 743 std::vector<std::vector<int> >* duplicates; 744 void insert_duplicate(int i1, int i2, std::vector<std::vector<int> >* dupl); 745 std::vector<int> process_results_vector; 680 746 }; 681 747
