gnugo-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[gnugo-devel] semeai tracing fixes


From: Arend Bayer
Subject: [gnugo-devel] semeai tracing fixes
Date: Wed, 5 Mar 2003 01:50:57 +0100 (CET)


A couple of fixes to semeai tracing.

Using the SGFTRACE2 macro in do_owl_analyze_semei was broken,
leading to "KO_B" or "GAIN" messages appering in the .sgf-files.
Fix thus with a new SGFTRACE_SEMEAI macro.

Dan, I assume when update_status() is called from new_semeai, it should
set the safety to "ALIVE_IN_SEKI" not "ALIVE", right? (See below.) --
That's what originally started confusing me.

Arend

Index: engine/semeai.c
===================================================================
RCS file: /cvsroot/gnugo/gnugo/engine/semeai.c,v
retrieving revision 1.52
diff -u -p -r1.52 semeai.c
--- engine/semeai.c     24 Feb 2003 02:52:27 -0000      1.52
+++ engine/semeai.c     5 Mar 2003 00:41:52 -0000
@@ -226,7 +226,7 @@ new_semeai(int color)
        }
       }
       else if (worst_result == ALIVE_IN_SEKI)
-       update_status(DRAGON(d1).origin, ALIVE, ALIVE);
+       update_status(DRAGON(d1).origin, ALIVE, ALIVE_IN_SEKI);
       else if (worst_result != UNKNOWN)
        update_status(DRAGON(d1).origin, worst_result, worst_result);
     }
Index: engine/board.c
===================================================================
RCS file: /cvsroot/gnugo/gnugo/engine/board.c,v
retrieving revision 1.66
diff -u -p -r1.66 board.c
--- engine/board.c      22 Feb 2003 10:54:23 -0000      1.66
+++ engine/board.c      5 Mar 2003 00:41:37 -0000
@@ -587,6 +587,7 @@ semeai_trymove(int pos, int color, const
                  message, sbuf1, sbuf2, count_variations, value);
     else
       gg_snprintf(buf, 100,
+                 "%s in semeai %s-%s (variation %d, value %d)",
                  message, sbuf1, sbuf2, count_variations, value);
     sgftreeAddPlayLast(sgf_dumptree, color, I(pos), J(pos));
     sgftreeAddComment(sgf_dumptree, buf);
Index: engine/cache.c
===================================================================
RCS file: /cvsroot/gnugo/gnugo/engine/cache.c,v
retrieving revision 1.20
diff -u -p -r1.20 cache.c
--- engine/cache.c      6 Feb 2003 16:27:00 -0000       1.20
+++ engine/cache.c      5 Mar 2003 00:41:38 -0000
@@ -811,8 +811,8 @@ sgf_trace(const char *func, int str, int
  */

 void
-sgf_trace2(const char *func, int str1, int str2, int move, int result,
-          const char *message)
+sgf_trace2(const char *func, int str1, int str2, int move,
+           const char *result, const char *message)
 {
   char buf[100];

@@ -820,16 +820,14 @@ sgf_trace2(const char *func, int str1, i
          J(str1) + 'A' + (J(str1) >= 8), board_size - I(str1),
          J(str2) + 'A' + (J(str2) >= 8), board_size - I(str2));

-  if (result == 0)
-    sprintf(buf + strlen(buf), "0");
-  else if (ON_BOARD(move))
-    sprintf(buf + strlen(buf), "%s %c%d", result_to_string(result),
+  if (ON_BOARD(move))
+    sprintf(buf + strlen(buf), "%s %c%d", result,
            J(move) + 'A' + (J(move) >= 8),
            board_size - I(move));
   else if (is_pass(move))
-    sprintf(buf + strlen(buf), "%s PASS", result_to_string(result));
+    sprintf(buf + strlen(buf), "%s PASS", result);
   else
-    sprintf(buf + strlen(buf), "%s [%d]", result_to_string(result), move);
+    sprintf(buf + strlen(buf), "%s [%d]", result, move);

   if (message)
     sprintf(buf + strlen(buf), " (%s)", message);
Index: engine/cache.h
===================================================================
RCS file: /cvsroot/gnugo/gnugo/engine/cache.h,v
retrieving revision 1.25
diff -u -p -r1.25 cache.h
--- engine/cache.h      6 Feb 2003 16:27:00 -0000       1.25
+++ engine/cache.h      5 Mar 2003 00:41:38 -0000
@@ -215,8 +215,8 @@ void hashnode_dump(Hashnode *node, FILE
 void sgf_trace(const char *func, int str, int move, int result,
               const char *message);
 /* Trace messages in decideconnection/decidesemeai sgf file. */
-void sgf_trace2(const char *func, int str1, int str2, int move, int result,
-               const char *message);
+void sgf_trace2(const char *func, int str1, int str2, int move,
+               const char* result, const char *message);

 /* Macro to hide the call to sgf_trace(). Notice that a little black
  * magic is going on here. Before using this macro, SETUP_TRACE_INFO
@@ -233,7 +233,13 @@ void sgf_trace2(const char *func, int st
  */
 #define SGFTRACE2(move, result, message) \
   if (sgf_dumptree) \
-    sgf_trace2(read_function_name, q1, q2, move, result, message)
+    sgf_trace2(read_function_name, q1, q2, move, \
+              result_to_string(result), message)
+
+#define SGFTRACE_SEMEAI(move, result, message) \
+  if (sgf_dumptree) \
+    sgf_trace2(read_function_name, q1, q2, move, \
+              safety_to_string(result), message)


 int get_read_result(int routine, int komaster, int kom_pos,
Index: engine/owl.c
===================================================================
RCS file: /cvsroot/gnugo/gnugo/engine/owl.c,v
retrieving revision 1.146
diff -u -p -r1.146 owl.c
--- engine/owl.c        25 Feb 2003 13:57:11 -0000      1.146
+++ engine/owl.c        5 Mar 2003 00:41:46 -0000
@@ -428,9 +428,8 @@ do_owl_analyze_semeai(int apos, int bpos
          TRACE("%oVariation %d: %1m ALIVE_IN_SEKI (cached)\n",
                this_variation_number, bpos);

-      SGFTRACE2(rr_get_move(*read_result),
-               rr_get_result1(*read_result),
-              "cached");
+      SGFTRACE_SEMEAI(rr_get_move(*read_result), rr_get_result1(*read_result),
+                     "cached");
       *resulta = rr_get_result1(*read_result);
       *resultb = rr_get_result2(*read_result);
       return;
@@ -476,7 +475,7 @@ do_owl_analyze_semeai(int apos, int bpos
        if (move) *move = upos;
        sgf_dumptree = save_sgf_dumptree;
        count_variations = save_count_variations;
-       SGFTRACE2(upos, ALIVE, "tactical win found");
+       SGFTRACE_SEMEAI(upos, ALIVE, "tactical win found");
        close_pattern_list(color, &shape_defensive_patterns);
        close_pattern_list(color, &shape_offensive_patterns);
        READ_RETURN_SEMEAI(read_result, move, upos, ALIVE, DEAD);
@@ -572,10 +571,10 @@ do_owl_analyze_semeai(int apos, int bpos
       sgf_dumptree = save_sgf_dumptree;
       count_variations = save_count_variations;
       if (max_eyes(&probable_eyes_b) == 0) {
-       SGFTRACE2(PASS_MOVE, ALIVE, "Two eyes versus none");
+       SGFTRACE_SEMEAI(PASS_MOVE, ALIVE, "Two eyes versus none");
       }
       else {
-       SGFTRACE2(PASS_MOVE, ALIVE, "Two eyes versus one");
+       SGFTRACE_SEMEAI(PASS_MOVE, ALIVE, "Two eyes versus one");
       }
       READ_RETURN_SEMEAI(read_result, move, PASS_MOVE, ALIVE, DEAD);
     }
@@ -590,10 +589,10 @@ do_owl_analyze_semeai(int apos, int bpos
        sgf_dumptree = save_sgf_dumptree;
        count_variations = save_count_variations;
        if (max_eyes(&probable_eyes_b) == 0) {
-         SGFTRACE2(PASS_MOVE, ALIVE, "Two eyes or escape versus none");
+         SGFTRACE_SEMEAI(PASS_MOVE, ALIVE, "Two eyes or escape versus none");
        }
        else {
-         SGFTRACE2(PASS_MOVE, ALIVE, "Two eyes or escape versus one");
+         SGFTRACE_SEMEAI(PASS_MOVE, ALIVE, "Two eyes or escape versus one");
        }
        READ_RETURN_SEMEAI(read_result, move, PASS_MOVE, ALIVE, DEAD);
       }
@@ -604,7 +603,7 @@ do_owl_analyze_semeai(int apos, int bpos
        if (move) *move = PASS_MOVE;
        sgf_dumptree = save_sgf_dumptree;
        count_variations = save_count_variations;
-       SGFTRACE2(PASS_MOVE, ALIVE, "Both live");
+       SGFTRACE_SEMEAI(PASS_MOVE, ALIVE, "Both live");
        READ_RETURN_SEMEAI(read_result, move, PASS_MOVE, ALIVE, ALIVE);
       }
       else if (vital_offensive_moves[0].pos != NO_MOVE){
@@ -615,12 +614,12 @@ do_owl_analyze_semeai(int apos, int bpos
        sgf_dumptree = save_sgf_dumptree;
        count_variations = save_count_variations;
        if (min_eyes(&probable_eyes_b) == 0) {
-         SGFTRACE2(vital_offensive_moves[0].pos,
-                   ALIVE, "Two eyes or escape versus none");
+         SGFTRACE_SEMEAI(vital_offensive_moves[0].pos,
+                         ALIVE, "Two eyes or escape versus none");
        }
        else
-         SGFTRACE2(vital_offensive_moves[0].pos,
-                   ALIVE, "Two eyes or escape versus one");
+         SGFTRACE_SEMEAI(vital_offensive_moves[0].pos,
+                         ALIVE, "Two eyes or escape versus one");
        READ_RETURN_SEMEAI(read_result, move, vital_offensive_moves[0].pos,
                           ALIVE, DEAD);
       }
@@ -640,7 +639,7 @@ do_owl_analyze_semeai(int apos, int bpos
        if (move) *move = PASS_MOVE;
        sgf_dumptree = save_sgf_dumptree;
        count_variations = save_count_variations;
-       SGFTRACE2(PASS_MOVE, DEAD, "You live, I die");
+       SGFTRACE_SEMEAI(PASS_MOVE, DEAD, "You live, I die");
        READ_RETURN_SEMEAI(read_result, move, PASS_MOVE, DEAD, ALIVE);
       }
       else if (min_eyes(&probable_eyes_a) >= 2) {
@@ -650,7 +649,7 @@ do_owl_analyze_semeai(int apos, int bpos
        if (move) *move = PASS_MOVE;
        sgf_dumptree = save_sgf_dumptree;
        count_variations = save_count_variations;
-       SGFTRACE2(PASS_MOVE, ALIVE, "Both live");
+       SGFTRACE_SEMEAI(PASS_MOVE, ALIVE, "Both live");
        READ_RETURN_SEMEAI(read_result, move, PASS_MOVE, ALIVE, ALIVE);
       }
       else if (vital_defensive_moves[0].pos != NO_MOVE) {
@@ -660,8 +659,7 @@ do_owl_analyze_semeai(int apos, int bpos
        if (move) *move = vital_defensive_moves[0].pos;
        sgf_dumptree = save_sgf_dumptree;
        count_variations = save_count_variations;
-       SGFTRACE2(vital_defensive_moves[0].pos, ALIVE,
-                 "Both live");
+       SGFTRACE_SEMEAI(vital_defensive_moves[0].pos, ALIVE, "Both live");
        READ_RETURN_SEMEAI(read_result, move, vital_defensive_moves[0].pos,
                           ALIVE, ALIVE);
       }
@@ -928,7 +926,7 @@ do_owl_analyze_semeai(int apos, int bpos
        *resulta = ALIVE;
        *resultb = DEAD;
        if (move) *move = mpos;
-       SGFTRACE2(mpos, ALIVE, moves[k].name);
+       SGFTRACE_SEMEAI(mpos, ALIVE, moves[k].name);
        close_pattern_list(color, &shape_defensive_patterns);
        close_pattern_list(color, &shape_offensive_patterns);
        READ_RETURN_SEMEAI(read_result, move, mpos, ALIVE, DEAD);
@@ -959,7 +957,7 @@ do_owl_analyze_semeai(int apos, int bpos
     *resulta = ALIVE_IN_SEKI;
     *resultb = ALIVE_IN_SEKI;
     if (move) *move = PASS_MOVE;
-    SGFTRACE2(PASS_MOVE, ALIVE_IN_SEKI, "Seki");
+    SGFTRACE_SEMEAI(PASS_MOVE, ALIVE_IN_SEKI, "Seki");
     READ_RETURN_SEMEAI(read_result, move, PASS_MOVE,
                       ALIVE_IN_SEKI, ALIVE_IN_SEKI);
   }
@@ -967,7 +965,7 @@ do_owl_analyze_semeai(int apos, int bpos
   if (best_resulta == UNKNOWN) {
     do_owl_analyze_semeai(bpos, apos, owlb, owla, komaster,
                          resultb, resulta, NULL, 1, owl_phase);
-    SGFTRACE2(PASS_MOVE, UNKNOWN, "No move found");
+    SGFTRACE_SEMEAI(PASS_MOVE, UNKNOWN, "No move found");
     if (move) *move = PASS_MOVE;
     READ_RETURN_SEMEAI(read_result, move, PASS_MOVE, *resulta, *resultb);
   }
@@ -977,7 +975,7 @@ do_owl_analyze_semeai(int apos, int bpos
   if (best_resulta == DEAD)
     best_move = PASS_MOVE;
   if (move) *move = best_move;
-  SGFTRACE2(best_move, best_resulta, moves[best_move_k].name);
+  SGFTRACE_SEMEAI(best_move, best_resulta, moves[best_move_k].name);
   READ_RETURN_SEMEAI(read_result, move, best_move, best_resulta, best_resultb);
 }






reply via email to

[Prev in Thread] Current Thread [Next in Thread]