gnugo-devel
[Top][All Lists]
Advanced

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

[gnugo-devel] edge_distance()


From: Arend Bayer
Subject: [gnugo-devel] edge_distance()
Date: Sun, 18 May 2003 14:39:02 +0200 (CEST)


- new function edge_distance()

Arend

Index: engine/value_moves.c
===================================================================
RCS file: /cvsroot/gnugo/gnugo/engine/value_moves.c,v
retrieving revision 1.92
diff -u -p -r1.92 value_moves.c
--- engine/value_moves.c        12 May 2003 08:50:42 -0000      1.92
+++ engine/value_moves.c        18 May 2003 12:39:01 -0000
@@ -1248,13 +1248,8 @@ strategic_penalty(int pos, int color)
          return 0.0;
        /* Third line moves (or lower) are ok -- they try to live, not run
          * away.
-        *
-        * FIXME: Add an "edge_distance()" function in board.c which can
-        *        be used here.
          */
-        if (gg_min(gg_min(I(pos), board_size-1 - I(pos)),
-                   gg_min(J(pos), board_size-1 - J(pos)))
-            < 3)
+        if (edge_distance(pos) < 3)
          return 0.0;

        for (i = 0; i < 4; i++)
Index: engine/liberty.h
===================================================================
RCS file: /cvsroot/gnugo/gnugo/engine/liberty.h,v
retrieving revision 1.171
diff -u -p -r1.171 liberty.h
--- engine/liberty.h    12 May 2003 19:28:32 -0000      1.171
+++ engine/liberty.h    18 May 2003 12:39:01 -0000
@@ -171,6 +171,9 @@ extern int position_number;
 /* Detect vertex on edge or corner. */
 int is_edge_vertex(int pos);
 int is_corner_vertex(int pos);
+int edge_distance(int pos);


 /* Count and/or find liberties at (pos). */
Index: engine/board.c
===================================================================
RCS file: /cvsroot/gnugo/gnugo/engine/board.c,v
retrieving revision 1.72
diff -u -p -r1.72 board.c
--- engine/board.c      22 Apr 2003 02:48:04 -0000      1.72
+++ engine/board.c      18 May 2003 12:39:04 -0000
@@ -1909,6 +1909,16 @@ is_edge_vertex(int pos)
 }


+int
+edge_distance(int pos)
+{
+  ASSERT_ON_BOARD1(pos);
+  int i = I(pos);
+  int j = J(pos);
+  return gg_min(gg_min(i, board_size-1 - i), gg_min(j, board_size-1 - j));
+}
+
+
 /* Determine whether vertex is a corner. */
 int
 is_corner_vertex(int pos)





reply via email to

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