gnugo-devel
[Top][All Lists]
Advanced

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

Re: [gnugo-devel] changed board_hash after reading


From: Gunnar Farnebäck
Subject: Re: [gnugo-devel] changed board_hash after reading
Date: Fri, 09 Sep 2005 20:59:19 +0200
User-agent: EMH/1.14.1 SEMI/1.14.3 (Ushinoya) FLIM/1.14.2 (Yagi-Nishiguchi) APEL/10.3 Emacs/21.3 (sparc-sun-solaris2.9) MULE/5.0 (SAKAKI)

Arend wrote:
> My conclusion is now:
> 1. I think Martin's patch is wrong on this point, as it does the check before
>    komaster_trymove had a chance to update the ko position (this should
>    also explain the increase in reading nodes).
> 2. I guess we should use Gunnar's latest patch.

What remains of my patch after martin_7_5.1 is appended below. There's
no breakage and slight (-0.089% -0.056% -0.014%) node reductions.

> To be pedantic, it may not be entirely correct in situation such as this
> (white to move is komaster for *):
>    A B C D E F G H J 
> 19 . . . . . . . . . 
> 18 . . X X O . . . . 
> 17 . . X O * O . . . 
> 16 . . . X O . . . . 
> 15 . . X O X . . . . 
> 14 . . X O . . . . . 
> 13 . . . . . . . . . 
> 
> Capturing D16 doesnt resolve the ko for all eternity if Black blocks at 
> B16 and later recaptures D16.
> 
> (But the code was probably never correct for this situation.)

No, komaster has never tried to handle this and I'm not completely
sure it should.

/Gunnar

Index: engine/board.c
===================================================================
RCS file: /cvsroot/gnugo/gnugo/engine/board.c,v
retrieving revision 1.112
diff -u -r1.112 board.c
--- engine/board.c      2 Sep 2005 18:03:02 -0000       1.112
+++ engine/board.c      9 Sep 2005 07:45:04 -0000
@@ -1226,25 +1226,6 @@
   int kpos;
   int previous_board_ko_pos = board_ko_pos;
 
-  /* First we check whether the ko claimed by komaster has been
-   * resolved. If that is the case, we revert komaster to EMPTY.
-   *
-   * The ko has been resolved in favor of the komaster if it has
-   * been filled, or if it is no longer a ko and an opponent move
-   * there is suicide.
-   */
-  if (((komaster == WHITE || komaster == GRAY_WHITE)
-       && (IS_STONE(board[kom_pos])
-          || (!is_ko(kom_pos, BLACK, NULL)
-              && is_suicide(kom_pos, BLACK))))
-      || ((komaster == BLACK || komaster == GRAY_BLACK)
-         && (IS_STONE(board[kom_pos])
-             || (!is_ko(kom_pos, WHITE, NULL)
-                 && is_suicide(kom_pos, WHITE))))) {
-    set_new_komaster(EMPTY);
-    set_new_kom_pos(NO_MOVE);
-  }
-
   *is_conditional_ko = 0;
   ko_move = is_ko(pos, color, &kpos);
 
@@ -1288,10 +1269,28 @@
   }
 
   if (!ko_move) {
+    /* If we are komaster, check whether the ko was resolved by the
+     * current move. If that is the case, revert komaster to EMPTY.
+     *
+     * The ko has been resolved in favor of the komaster if it has
+     * been filled, or if it is no longer a ko and an opponent move
+     * there is suicide.
+     */
+    if (((komaster == color
+         || (komaster == GRAY_WHITE && color == WHITE)
+         || (komaster == GRAY_BLACK && color == BLACK))
+        && (IS_STONE(board[kom_pos])
+            || (!is_ko(kom_pos, other, NULL)
+                && is_suicide(kom_pos, other))))) {
+      set_new_komaster(EMPTY);
+      set_new_kom_pos(NO_MOVE);
+    }
+
     if (komaster == WEAK_KO) {
       set_new_komaster(EMPTY);
       set_new_kom_pos(NO_MOVE);
     }
+    
     return 1;
   }
 




reply via email to

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