From 10ad687e7d85f3da51b7a562d517fed83a9e6192 Mon Sep 17 00:00:00 2001 From: Maurizio Monge Date: Thu, 11 Oct 2007 20:14:37 +0200 Subject: [PATCH] Fixed sideeffects of enabling the gui to visualize the search tree. --- CMakeLists.txt | 6 +++--- rattatechess.ini | 2 +- search.cpp | 9 +++++---- search.h | 2 +- search_gui.cpp | 9 +++++---- search_gui.h | 9 ++++++--- 6 files changed, 21 insertions(+), 16 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 3178f54..fe620eb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -27,9 +27,9 @@ MACRO(ADDCFLAG SRCFILE FLAG) ENDMACRO(ADDCFLAG SRCFILE FLAG) -SET(GUI 0) -#SET(CMAKE_BUILD_TYPE Debug) -SET(CMAKE_BUILD_TYPE Release) +SET(GUI 1) +SET(CMAKE_BUILD_TYPE Debug) +#SET(CMAKE_BUILD_TYPE Release) #SET(CMAKE_BUILD_TYPE Profile) SET(CMAKE_C_FLAGS_RELEASE "-O3 -fomit-frame-pointer -fexpensive-optimizations -fno-strict-aliasing -Wall") diff --git a/rattatechess.ini b/rattatechess.ini index b7b514e..a3e4e84 100644 --- a/rattatechess.ini +++ b/rattatechess.ini @@ -2,4 +2,4 @@ #open_book "/home/maurizio/ratta.book" open_lines "ratta.lines" open_eco "ratta.eco" -#_gon \ No newline at end of file +_gon \ No newline at end of file diff --git a/search.cpp b/search.cpp index 66f3a9a..ecbba6d 100644 --- a/search.cpp +++ b/search.cpp @@ -584,7 +584,7 @@ int16_t SearchRoot::search(int ply, int base_depth, bool pv, int16_t orig_alpha, s->curr_move = -1; board.do_null_move(s->save_buf); - GUI1(notify(&board, Move::None(), ply, sdepth, -INF, beta-1, beta, SearchGui::Green )); + GUI1(notify(&board, Move::None(), ply, sdepth, -INF, beta-NULL_SOLIDITY_MARGIN, beta, SearchGui::Green )); val = -search( ply+1, sdepth, false, -beta, -beta+NULL_SOLIDITY_MARGIN, false); GUI2(notify_value(ply, val, DIFF_NODES, SearchGui::Bold )); board.undo_null_move(s->save_buf); @@ -705,10 +705,11 @@ int16_t SearchRoot::search(int ply, int base_depth, bool pv, int16_t orig_alpha, #if INTERNAL_ITERATIVE_DEEPENING else if(base_depth>3*PLY && pv) /* don't do it only on the pv, or it will be useless :) */ { + int val; s->curr_move = -2; GUI1(notify(&board, Move::None(), ply, base_depth-2*PLY, -INF, alpha, beta, SearchGui::Blue )); - int val = search(ply+1, base_depth-2*PLY, true, alpha, beta, expect_allbad); - GUI2(search_gui->notify_value(ply, val, DIFF_NODES, 0)); + val = search(ply+1, base_depth-2*PLY, true, alpha, beta, expect_allbad); + GUI2(notify_value(ply, val, DIFF_NODES, 0)); HashEntry *h2 = probe_hash( board.hash ); if(h2 && h2->best_mv) @@ -1141,7 +1142,7 @@ Move Engine::find_best_move() } reset_stats(); - IFGUI(reset_hash()); //Try to be deterministic + reset_hash(); //Try to be deterministic processed_nodes = 0; thinking = true; make_old_hash(); diff --git a/search.h b/search.h index 1aa80b6..a0619ff 100644 --- a/search.h +++ b/search.h @@ -28,7 +28,7 @@ // #define MP(_x) ({int x = _x; x = (x - (x>>16))&0xffff; x<0?x+PLUTO_SIZE:x;}) //#define PLUTO_SIZE 577177 #define PLUTO_SIZE 277177 -#define MP(x) (((unsigned int)(x))%PLUTO_SIZE) +#define MP(x) ((int)(((unsigned int)(x))%PLUTO_SIZE)) #define CAPT_INDEX(m) ({Move _m=(m);_m.capture*128*128 + _m.from*128 + _m.to;}) #define PLUTO_INDEX(a,b) MP(CAPT_INDEX(a)*9829+CAPT_INDEX(b)) diff --git a/search_gui.cpp b/search_gui.cpp index fbbb90f..efed05b 100644 --- a/search_gui.cpp +++ b/search_gui.cpp @@ -133,7 +133,7 @@ void SearchGui::notify_value(int ply, int value, int nodecount, int newflags) apply_flags(item, newflags); } -void SearchGui::notify(Board *board, Move m, int ply, int depth, int heuval, int alpha, int beta, int flags) +void SearchGui::notify(const Board *board, Move m, int ply, int depth, int heuval, int alpha, int beta, int flags) { if(ply>max_ply) return; @@ -144,9 +144,10 @@ void SearchGui::notify(Board *board, Move m, int ply, int depth, int heuval, int else { SaveBuf tmp; - board->undo_move(m, tmp); - board->move_to_alg(str, m); - board->do_move(m, tmp); + Board b = *board; + b.undo_move(m, tmp); + b.move_to_alg(str, m); + b.do_move(m, tmp); if(heuval != -INF) sprintf(str+strlen(str), "(%d)", heuval); } diff --git a/search_gui.h b/search_gui.h index fbe8bea..6d17c78 100644 --- a/search_gui.h +++ b/search_gui.h @@ -50,7 +50,7 @@ public: static void apply_flags(QTreeWidgetItem* w, int flags); void init_root(); void new_root_level(int depth); - void notify(Board *board, Move m, int ply, int depth, int heuval, int alpha, int beta, int flags); + void notify(const Board *board, Move m, int ply, int depth, int heuval, int alpha, int beta, int flags); void notify_value(int ply, int value, int nodecount, int newflags); void notify_eval(int ply, int value, int alpha, int beta, int flags); void notify_hash(int ply, int lower, int upper, int depth, int alpha, int beta, Move best, bool write, int flags); @@ -59,11 +59,14 @@ public: }; #define DIFF_NODES (engine->processed_nodes-__nc) -#define GUI1(a) {uint64_t __nc = engine->processed_nodes; if(search_gui) search_gui->a; else {} -#define GUI2(a) if(search_gui) search_gui->a; else {} } +#define GUI1(a) {uint64_t __nc = engine->processed_nodes; if(search_gui) { search_gui->a; } else {} +#define GUI2(a) if(search_gui) { search_gui->a; } else {} } #define GUI(a) if(search_gui) search_gui->a; else {} #define IFGUI(a) a +// #define GUI1(a) +// #define GUI2(a) + #else class SearchGui -- 2.11.4.GIT