gnugo-devel
[Top][All Lists]
Advanced

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

[gnugo-devel] Inducing secondary connections from connecting moves


From: Portela Fernand
Subject: [gnugo-devel] Inducing secondary connections from connecting moves
Date: Mon, 11 Nov 2002 19:31:21 +0100

Hi,

Recently, I noticed following in a Gnu Go game :

.OX.
O...
XO*O
X.X.

While valuing a move at *, Gnu Go only recorded a connection between the
2 lower stones, while actually the move was connecting together the 4 O
stones (which weren't amalgamated, that is, they were 4 separate dragons) 

The following patch tries to address this issue. I added a few code lines
in induce_secondary_move_reasons() that scan for neighboring inhibited
connections if a connect move happens to be played on a similar point (i.e.
also inhibited). If such points are found, it is tested that the
connections cannot be broken and connect moves are added as needed.

With following regression breakage results :

nicklas2:102   PASS

  Gnu Go still doesn't completely understand the move (it doesn't realize
  what would happen if it wouldn't be played). But choosing this move for
  its connectivity properties is very good anyway IMHO.

tervor:412     PASS

  Gnu Go now prefers C4 because it connects the stones to the dragon on
  the top. Very good IMO.

13x13:41       PASS

  Gnu Go now prefers H10. While there is an improvement (H10 is very good
  I think, makes an eye and connects), C8 still isn't considered an error.

nngs3:1080     FAIL

  Intricate situation where Gnu Go doesn't see the loss of J5 coming. I
  think that if we were to do what Arend proposed recently, e.g. upgrade
  connecting moves involving a critical dragon and a living one to owl
  defenses, then the problem would be detected and prevented by the
  blunder_size() code.


A side note about the position which led me into this patch.

.OX.     Gnu Go didn't consider this move which also connects everything
O.*.     and has the advantage of being sente (in that context) against
XO.O     the top X stone.
X.X.

  
/nando

PS: I haven't tested, but it shouldn't clash with Arend's patch I think.


Index: engine/value_moves.c
===================================================================
RCS file: /cvsroot/gnugo/gnugo/engine/value_moves.c,v
retrieving revision 1.65
diff -u -r1.65 value_moves.c
--- engine/value_moves.c        20 Oct 2002 10:40:45 -0000      1.65
+++ engine/value_moves.c        11 Nov 2002 17:11:21 -0000
@@ -432,6 +432,14 @@
 
 
 
+static int 
+bdist(int pos1, int pos2)
+{
+  int idist = I(pos1) - I(pos2);
+  int jdist = J(pos1) - J(pos2);
+  return idist*idist + jdist*jdist;
+}
+
 /*
  * Any move that captures or defends a worm also potentially connects
  * or cuts the surrounding strings. Find these secondary move reasons
@@ -441,6 +449,15 @@
  * neighbors of the owl attacked dragon. We only do this for
  * tactically safe dragons, however, because otherwise the effects of
  * capturing have already been taken into account elsewhere.
+ *
+ * Also, connecting moves played on inhibited points possibly remove
+ * nearby connection inhibitions like in following example :
+ * 
+ * .OX.   The * move connects _all_ O stones together, not only
+ * O...   the 2 lower ones.
+ * XO*O
+ * X.X.
+ *
  */
 
 static void
@@ -562,6 +579,31 @@
            add_strategical_defense_move(pos, bb);
        }
       }
+      else if (move_reasons[r].type == CONNECT_MOVE
+             && cut_possible(pos, OTHER_COLOR(color))) {
+       int worm1 = worms[conn_worm1[move_reasons[r].what]];
+       int worm2 = worms[conn_worm2[move_reasons[r].what]];
+       int pos2;
+       for (pos2 = BOARDMIN; pos2 < BOARDMAX; pos2++)
+         if (ON_BOARD(pos2) && board[pos2] == EMPTY
+             && cut_possible(pos2, OTHER_COLOR(color))
+             && bdist(pos, pos2) <= 5)
+           for (j = 0; j < 8; j++) {
+             int pos3 = pos2 + delta[j];
+             if (ON_BOARD(pos3) && board[pos3] == color
+                 && !is_same_worm(pos3, worm1)
+                 && !is_same_worm(pos3, worm2)) {
+               if (trymove(pos, color, "induce_secondary_move_reasons-B",
+                           worm1, EMPTY, NO_MOVE)) {
+                 if (!disconnect(pos3, worm1, NULL))
+                   add_connection_move(pos, pos3, worm1);
+                 if (!disconnect(pos3, worm2, NULL))
+                   add_connection_move(pos, pos3, worm2);
+                 popgo();
+               }
+             }
+           }
+      }
     }
   }
 }




reply via email to

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