version 1.4.39b
[polyglot.git] / book.c
diff --git a/book.c b/book.c
index 950e2f9..c81df43 100644 (file)
--- a/book.c
+++ b/book.c
@@ -144,7 +144,7 @@ int book_move(const board_t * board, bool random) {
 \r
       if (move != MoveNone &&\r
           move_is_legal(move,board) &&\r
-          score/10>option_get_int(Option,"BookTreshold")) {\r
+          score>10*option_get_int(Option,"BookTreshold")) {\r
 \r
          // pick this move?\r
 \r
@@ -212,10 +212,10 @@ void book_moves(list_t * list, const board_t * board) {
       if (entry->key != board->key) break;\r
 \r
       move = entry->move;\r
-      score = (entry->count*10000)/sum;  // 32 bit safe!\r
+      score = (((uint32)entry->count)*((uint32)10000))/sum;  // 32 bit safe!\r
 \r
-      if (score > 0 && move != MoveNone && move_is_legal(move,board)) {\r
-          list_add_ex(list,move,score);\r
+      if (move != MoveNone && move_is_legal(move,board)) {\r
+              list_add_ex(list,move,score);\r
       }\r
    }\r
 \r
@@ -229,6 +229,7 @@ void book_disp(const board_t * board) {
    char move_string[256];\r
    list_t list[1];\r
    int i;\r
+   int treshold=option_get_int(Option,"BookTreshold");\r
 \r
    ASSERT(board!=NULL);\r
 \r
@@ -238,8 +239,15 @@ void book_disp(const board_t * board) {
    \r
    for(i=0; i<list_size(list); i++){\r
        move_to_san(list->move[i],board,move_string,256);\r
-       printf(" %6s %5.2f%%\n",move_string,list->value[i]/100.0);\r
+       if(list->value[i]>10*treshold){\r
+           printf(" %6s %5.2f%%\n",move_string,list->value[i]/100.0);\r
+       }else{\r
+           printf(" %6s %5.2f%% (below treshold %4.2f%%)\n",\r
+                  move_string,list->value[i]/100.0,treshold/10.0);\r
+       }\r
    }\r
+   // this is necessary by the xboard protocol\r
+   printf("\n");\r
 }\r
 \r
 // book_learn_move()\r